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

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

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

b.v = m
l.w = b
m.v = b
assert l.w.v.v.txt == "
class A:
    def __init__(self, txt: str):
        self.v: A = None
        self.txt = txt

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

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

b.v = m
l.w = b
m.v = b
assert l.w.v.v.txt == "b"