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

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

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

l.x = i
c.r = i
a.r = l
i.x = l
assert i.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.r: A = None
        self.txt = txt

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

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