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

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

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

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

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

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

d.x = l
c.t = l
l.x = d
assert l.x.x.x.txt == "d"