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

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

l = A("l")
e = B("e")
f = B("f")

l.u = e
e.r = f
f.r = e
assert e.r.r.r.txt == "
class A:
    def __init__(self, txt: str):
        self.u: B = None
        self.txt = txt

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

l = A("l")
e = B("e")
f = B("f")

l.u = e
e.r = f
f.r = e
assert e.r.r.r.txt == "f"