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

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

k = A("k")
m = B("m")
d = B("d")
l = B("l")
f = B("f")
j = A("j")
a = B("a")
e = A("e")
c = B("c")
i = A("i")

k.w = l
k.u = i
m.o = c
m.w = a
d.o = m
d.w = f
l.o = f
l.w = f
f.o = l
f.w = l
j.w = m
j.u = k
a.o = d
a.w = l
e.w = m
e.u = k
c.o = m
c.w = m
i.w = f
i.u = k
assert d.w.w.o.w.txt == "
class A:
    def __init__(self, txt: str):
        self.w: B = None
        self.u: A = None
        self.txt = txt

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

k = A("k")
m = B("m")
d = B("d")
l = B("l")
f = B("f")
j = A("j")
a = B("a")
e = A("e")
c = B("c")
i = A("i")

k.w = l
k.u = i
m.o = c
m.w = a
d.o = m
d.w = f
l.o = f
l.w = f
f.o = l
f.w = l
j.w = m
j.u = k
a.o = d
a.w = l
e.w = m
e.u = k
c.o = m
c.w = m
i.w = f
i.u = k
assert d.w.w.o.w.txt == "l"