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

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

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

m = A("m")
a = B("a")
h = C("h")
e = B("e")
d = B("d")
n = C("n")
k = C("k")
c = B("c")

m.x = h
m.w = e
a.u = m
a.t = m
h.z = k
e.u = m
e.t = m
d.u = m
d.t = m
n.z = k
k.z = n
c.u = m
c.t = m
assert a.t.x.z.z.txt == "
class A:
    def __init__(self, txt: str):
        self.x: C = None
        self.w: B = None
        self.txt = txt

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

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

m = A("m")
a = B("a")
h = C("h")
e = B("e")
d = B("d")
n = C("n")
k = C("k")
c = B("c")

m.x = h
m.w = e
a.u = m
a.t = m
h.z = k
e.u = m
e.t = m
d.u = m
d.t = m
n.z = k
k.z = n
c.u = m
c.t = m
assert a.t.x.z.z.txt == "n"