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

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

c = A("c")
d = B("d")
b = B("b")

c.x = d
c.v = b
d.t = b
b.t = d
assert d.t.t.t.txt == "
class A:
    def __init__(self, txt: str):
        self.x: B = None
        self.v: B = None
        self.txt = txt

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

c = A("c")
d = B("d")
b = B("b")

c.x = d
c.v = b
d.t = b
b.t = d
assert d.t.t.t.txt == "b"