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

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

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

a = A("a")
f = B("f")
m = C("m")
l = A("l")

a.t = l
f.p = a
m.z = a
l.t = a
assert a.t.t.t.t.txt == "
class A:
    def __init__(self, txt: str):
        self.t: A = None
        self.txt = txt

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

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

a = A("a")
f = B("f")
m = C("m")
l = A("l")

a.t = l
f.p = a
m.z = a
l.t = a
assert a.t.t.t.t.txt == "a"