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

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

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

b = A("b")
f = B("f")
g = C("g")

b.z = f
f.t = b
g.t = b
assert b.z.t.z.txt == "
class A:
    def __init__(self, txt: str):
        self.z: B = None
        self.txt = txt

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

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

b = A("b")
f = B("f")
g = C("g")

b.z = f
f.t = b
g.t = b
assert b.z.t.z.txt == "f"