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

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

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

k = A("k")
d = B("d")
h = C("h")
g = C("g")
a = C("a")
e = C("e")

k.z = e
k.u = e
d.q = k
d.r = a
h.u = d
g.u = d
a.u = d
e.u = d
assert a.u.q.u.u.txt == "
class A:
    def __init__(self, txt: str):
        self.z: C = None
        self.u: C = None
        self.txt = txt

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

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

k = A("k")
d = B("d")
h = C("h")
g = C("g")
a = C("a")
e = C("e")

k.z = e
k.u = e
d.q = k
d.r = a
h.u = d
g.u = d
a.u = d
e.u = d
assert a.u.q.u.u.txt == "d"