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

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

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

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

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

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

m.w = a
l.u = m
a.u = m
assert a.u.w.u.txt == "m"