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

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

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

e = A("e")
j = B("j")
b = C("b")
i = A("i")
k = B("k")
c = B("c")
g = A("g")

e.u = b
e.t = g
j.z = b
j.r = k
b.z = k
i.u = b
i.t = e
k.z = b
k.r = j
c.z = b
c.r = k
g.u = b
g.t = e
assert c.z.z.z.z.r.r.r.txt == "
class A:
    def __init__(self, txt: str):
        self.u: C = None
        self.t: A = None
        self.txt = txt

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

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

e = A("e")
j = B("j")
b = C("b")
i = A("i")
k = B("k")
c = B("c")
g = A("g")

e.u = b
e.t = g
j.z = b
j.r = k
b.z = k
i.u = b
i.t = e
k.z = b
k.r = j
c.z = b
c.r = k
g.u = b
g.t = e
assert c.z.z.z.z.r.r.r.txt == "j"