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

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

b = A("b")
j = B("j")
l = A("l")

b.o = l
j.r = b
l.o = b
assert l.o.o.o.txt == "
class A:
    def __init__(self, txt: str):
        self.o: A = None
        self.txt = txt

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

b = A("b")
j = B("j")
l = A("l")

b.o = l
j.r = b
l.o = b
assert l.o.o.o.txt == "b"