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

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

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

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

a.x = h
k.s = h
k.z = i
e.u = m
e.z = d
f.s = h
f.z = b
i.u = e
i.z = k
h.x = a
b.u = e
b.z = k
m.u = i
m.z = k
d.s = a
d.z = e
assert a.x.x.x.x.txt == "
class A:
    def __init__(self, txt: str):
        self.x: A = None
        self.txt = txt

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

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

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

a.x = h
k.s = h
k.z = i
e.u = m
e.z = d
f.s = h
f.z = b
i.u = e
i.z = k
h.x = a
b.u = e
b.z = k
m.u = i
m.z = k
d.s = a
d.z = e
assert a.x.x.x.x.txt == "a"