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

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

e = A("e")
g = B("g")
m = B("m")
l = A("l")
h = A("h")
j = B("j")
f = B("f")
i = A("i")
b = A("b")
n = B("n")

e.w = b
g.t = n
m.t = n
l.w = e
h.w = e
j.t = g
f.t = m
i.w = e
b.w = h
n.t = j
assert h.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.t: B = None
        self.txt = txt

e = A("e")
g = B("g")
m = B("m")
l = A("l")
h = A("h")
j = B("j")
f = B("f")
i = A("i")
b = A("b")
n = B("n")

e.w = b
g.t = n
m.t = n
l.w = e
h.w = e
j.t = g
f.t = m
i.w = e
b.w = h
n.t = j
assert h.w.w.w.w.w.w.w.txt == "e"