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

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

a = A("a")
l = B("l")
c = A("c")
i = B("i")

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

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

a = A("a")
l = B("l")
c = A("c")
i = B("i")

a.t = i
l.x = i
c.t = l
i.x = l
assert i.x.x.x.txt == "l"