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

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

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

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

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

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

a.y = l
a.w = m
e.u = l
e.x = a
k.u = l
k.x = m
m.y = l
m.w = a
l.u = e
l.x = m
assert m.w.w.y.x.txt == "m"