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

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

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

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

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

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

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