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

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

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

b.r = l
a.y = l
l.y = a
assert b.r.y.y.txt == "
class A:
    def __init__(self, txt: str):
        self.r: B = None
        self.txt = txt

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

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

b.r = l
a.y = l
l.y = a
assert b.r.y.y.txt == "l"