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

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

b = A("b")
k = B("k")
h = B("h")
d = A("d")
i = A("i")
f = A("f")
j = A("j")
l = A("l")

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

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

b = A("b")
k = B("k")
h = B("h")
d = A("d")
i = A("i")
f = A("f")
j = A("j")
l = A("l")

b.w = h
b.u = k
k.y = h
h.y = k
d.w = k
d.u = h
i.w = h
i.u = h
f.w = h
f.u = h
j.w = h
j.u = h
l.w = h
l.u = k
assert l.w.y.y.y.y.y.y.txt == "h"