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

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

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

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

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

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

m.w = a
m.x = a
a.r = l
a.o = l
l.w = a
l.x = a
assert a.o.x.r.txt == "l"