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

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

l = A("l")
e = B("e")
g = A("g")
a = A("a")
j = B("j")
d = B("d")
b = B("b")
n = B("n")
i = B("i")
h = B("h")

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

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

l = A("l")
e = B("e")
g = A("g")
a = A("a")
j = B("j")
d = B("d")
b = B("b")
n = B("n")
i = B("i")
h = B("h")

l.t = a
l.z = a
e.w = h
g.t = l
g.z = l
a.t = g
a.z = g
j.w = e
d.w = e
b.w = n
n.w = b
i.w = e
h.w = d
assert n.w.w.w.w.w.w.w.w.w.w.txt == "n"