class A:
    def __init__(self, txt: str):
        self.o: B = None
        self.p: A = None
        self.x: B = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.u: C = None
        self.w: C = None
        self.txt = txt

class C:
    def __init__(self, txt: str):
        self.s: A = None
        self.txt = txt

i = A("i")
k = B("k")
j = C("j")
a = B("a")
m = A("m")
f = A("f")
b = C("b")
d = C("d")
g = B("g")
n = C("n")

i.o = a
i.p = f
i.x = k
k.u = n
k.w = b
j.s = i
a.u = j
a.w = n
m.o = g
m.p = i
m.x = k
f.o = a
f.p = m
f.x = k
b.s = f
d.s = i
g.u = n
g.w = b
n.s = i
assert n.s.p.o.w.s.o.w.s.o.txt == "
class A:
    def __init__(self, txt: str):
        self.o: B = None
        self.p: A = None
        self.x: B = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.u: C = None
        self.w: C = None
        self.txt = txt

class C:
    def __init__(self, txt: str):
        self.s: A = None
        self.txt = txt

i = A("i")
k = B("k")
j = C("j")
a = B("a")
m = A("m")
f = A("f")
b = C("b")
d = C("d")
g = B("g")
n = C("n")

i.o = a
i.p = f
i.x = k
k.u = n
k.w = b
j.s = i
a.u = j
a.w = n
m.o = g
m.p = i
m.x = k
f.o = a
f.p = m
f.x = k
b.s = f
d.s = i
g.u = n
g.w = b
n.s = i
assert n.s.p.o.w.s.o.w.s.o.txt == "a"