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

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

n = A("n")
h = B("h")
e = A("e")
i = B("i")
g = A("g")
m = A("m")
k = A("k")
b = A("b")
f = A("f")
a = A("a")

n.t = i
n.w = g
h.x = i
e.t = h
e.w = b
i.x = h
g.t = h
g.w = k
m.t = i
m.w = k
k.t = i
k.w = f
b.t = h
b.w = a
f.t = h
f.w = n
a.t = h
a.w = m
assert n.t.x.x.x.txt == "
class A:
    def __init__(self, txt: str):
        self.t: B = None
        self.w: A = None
        self.txt = txt

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

n = A("n")
h = B("h")
e = A("e")
i = B("i")
g = A("g")
m = A("m")
k = A("k")
b = A("b")
f = A("f")
a = A("a")

n.t = i
n.w = g
h.x = i
e.t = h
e.w = b
i.x = h
g.t = h
g.w = k
m.t = i
m.w = k
k.t = i
k.w = f
b.t = h
b.w = a
f.t = h
f.w = n
a.t = h
a.w = m
assert n.t.x.x.x.txt == "h"