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

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

class C:
    def __init__(self, txt: str):
        self.y: A = None
        self.x: B = None
        self.q: B = None
        self.txt = txt

a = A("a")
e = B("e")
m = C("m")
k = B("k")
f = C("f")
d = C("d")
b = A("b")
i = C("i")
c = B("c")
n = B("n")

a.w = m
e.t = a
e.w = n
e.y = d
m.y = a
m.x = e
m.q = e
k.t = b
k.w = n
k.y = m
f.y = a
f.x = c
f.q = n
d.y = a
d.x = c
d.q = n
b.w = m
i.y = a
i.x = k
i.q = c
c.t = a
c.w = e
c.y = d
n.t = b
n.w = k
n.y = f
assert a.w.x.y.y.w.txt == "
class A:
    def __init__(self, txt: str):
        self.w: C = None
        self.txt = txt

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

class C:
    def __init__(self, txt: str):
        self.y: A = None
        self.x: B = None
        self.q: B = None
        self.txt = txt

a = A("a")
e = B("e")
m = C("m")
k = B("k")
f = C("f")
d = C("d")
b = A("b")
i = C("i")
c = B("c")
n = B("n")

a.w = m
e.t = a
e.w = n
e.y = d
m.y = a
m.x = e
m.q = e
k.t = b
k.w = n
k.y = m
f.y = a
f.x = c
f.q = n
d.y = a
d.x = c
d.q = n
b.w = m
i.y = a
i.x = k
i.q = c
c.t = a
c.w = e
c.y = d
n.t = b
n.w = k
n.y = f
assert a.w.x.y.y.w.txt == "m"