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

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

i = A("i")
b = B("b")
l = B("l")
d = A("d")
a = B("a")
f = A("f")
h = A("h")
k = A("k")
n = A("n")
e = B("e")

i.w = k
b.o = l
b.z = e
l.o = b
l.z = a
d.w = k
a.o = l
a.z = e
f.w = h
h.w = f
k.w = d
n.w = k
e.o = b
e.z = a
assert i.w.w.w.w.w.w.w.txt == "
class A:
    def __init__(self, txt: str):
        self.w: A = None
        self.txt = txt

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

i = A("i")
b = B("b")
l = B("l")
d = A("d")
a = B("a")
f = A("f")
h = A("h")
k = A("k")
n = A("n")
e = B("e")

i.w = k
b.o = l
b.z = e
l.o = b
l.z = a
d.w = k
a.o = l
a.z = e
f.w = h
h.w = f
k.w = d
n.w = k
e.o = b
e.z = a
assert i.w.w.w.w.w.w.w.txt == "k"