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

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

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

b = A("b")
c = B("c")
l = C("l")
f = B("f")
j = C("j")
h = A("h")

b.t = h
b.z = f
c.u = f
l.u = h
f.u = c
j.u = b
h.t = b
h.z = f
assert b.t.t.t.z.txt == "
class A:
    def __init__(self, txt: str):
        self.t: A = None
        self.z: B = None
        self.txt = txt

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

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

b = A("b")
c = B("c")
l = C("l")
f = B("f")
j = C("j")
h = A("h")

b.t = h
b.z = f
c.u = f
l.u = h
f.u = c
j.u = b
h.t = b
h.z = f
assert b.t.t.t.z.txt == "f"