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

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

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

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

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

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

l.u = m
l.w = f
f.x = m
m.u = l
m.w = f
assert l.w.x.u.txt == "l"