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

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

l = A("l")
i = B("i")
b = B("b")
n = A("n")
c = A("c")
d = B("d")
e = A("e")
k = B("k")

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

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

l = A("l")
i = B("i")
b = B("b")
n = A("n")
c = A("c")
d = B("d")
e = A("e")
k = B("k")

l.u = b
i.w = k
b.w = d
n.u = b
c.u = b
d.w = i
e.u = b
k.w = i
assert l.u.w.w.w.txt == "k"