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

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

e = A("e")
j = B("j")
h = A("h")
b = A("b")
g = B("g")
f = A("f")
d = A("d")
n = B("n")
c = B("c")
i = A("i")

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

e = A("e")
j = B("j")
h = A("h")
b = A("b")
g = B("g")
f = A("f")
d = A("d")
n = B("n")
c = B("c")
i = A("i")

e.w = b
j.t = e
h.w = d
b.w = i
g.t = f
f.w = d
d.w = i
n.t = h
c.t = d
i.w = h
assert i.w.w.w.w.w.w.w.w.w.w.txt == "h"