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

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

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

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

e.w = c
c.u = m
h.z = b
h.r = d
k.w = b
b.u = k
d.z = c
d.r = h
f.w = c
m.w = c
a.w = b
assert k.w.u.w.txt == "
class A:
    def __init__(self, txt: str):
        self.w: B = None
        self.txt = txt

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

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

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

e.w = c
c.u = m
h.z = b
h.r = d
k.w = b
b.u = k
d.z = c
d.r = h
f.w = c
m.w = c
a.w = b
assert k.w.u.w.txt == "b"