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

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

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

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

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

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

l.u = e
l.w = n
k.s = a
k.o = l
e.s = a
e.o = l
a.s = e
a.o = n
m.s = e
m.o = n
n.u = e
n.w = l
assert a.o.w.w.txt == "n"