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

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

b = A("b")
f = B("f")
i = B("i")
c = A("c")

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

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

b = A("b")
f = B("f")
i = B("i")
c = A("c")

b.t = i
b.r = i
f.z = i
i.z = f
c.t = i
c.r = f
assert i.z.z.z.z.txt == "i"