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

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

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

l.x = a
l.w = a
m.z = e
m.s = l
e.z = a
e.s = b
b.x = m
b.w = e
a.z = e
a.s = b
assert m.s.w.s.w.txt == "
class A:
    def __init__(self, txt: str):
        self.x: B = None
        self.w: B = None
        self.txt = txt

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

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

l.x = a
l.w = a
m.z = e
m.s = l
e.z = a
e.s = b
b.x = m
b.w = e
a.z = e
a.s = b
assert m.s.w.s.w.txt == "e"