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

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

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

c = A("c")
b = B("b")
i = C("i")
a = A("a")
f = A("f")
l = C("l")
g = A("g")
m = C("m")

c.z = f
b.u = l
i.u = g
i.z = b
i.t = b
a.z = c
f.z = a
l.u = g
l.z = b
l.t = b
g.z = c
m.u = a
m.z = b
m.t = b
assert g.z.z.z.z.z.txt == "
class A:
    def __init__(self, txt: str):
        self.z: A = None
        self.txt = txt

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

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

c = A("c")
b = B("b")
i = C("i")
a = A("a")
f = A("f")
l = C("l")
g = A("g")
m = C("m")

c.z = f
b.u = l
i.u = g
i.z = b
i.t = b
a.z = c
f.z = a
l.u = g
l.z = b
l.t = b
g.z = c
m.u = a
m.z = b
m.t = b
assert g.z.z.z.z.z.txt == "f"