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

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

l = A("l")
k = B("k")
j = A("j")
f = A("f")
e = B("e")
h = B("h")
n = B("n")
d = B("d")

l.u = h
l.w = k
k.w = l
j.u = d
j.w = h
f.u = h
f.w = n
e.w = f
h.w = l
n.w = j
d.w = l
assert l.u.w.w.w.w.w.txt == "
class A:
    def __init__(self, txt: str):
        self.u: B = None
        self.w: B = None
        self.txt = txt

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

l = A("l")
k = B("k")
j = A("j")
f = A("f")
e = B("e")
h = B("h")
n = B("n")
d = B("d")

l.u = h
l.w = k
k.w = l
j.u = d
j.w = h
f.u = h
f.w = n
e.w = f
h.w = l
n.w = j
d.w = l
assert l.u.w.w.w.w.w.txt == "l"