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

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

n = A("n")
m = B("m")
e = A("e")
a = B("a")
i = B("i")
l = A("l")
b = A("b")
h = A("h")

n.u = h
n.o = e
m.p = a
m.v = h
e.u = h
e.o = n
a.p = m
a.v = n
i.p = a
i.v = e
l.u = e
l.o = b
b.u = l
b.o = l
h.u = b
h.o = l
assert i.p.v.o.o.o.o.u.u.txt == "
class A:
    def __init__(self, txt: str):
        self.u: A = None
        self.o: A = None
        self.txt = txt

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

n = A("n")
m = B("m")
e = A("e")
a = B("a")
i = B("i")
l = A("l")
b = A("b")
h = A("h")

n.u = h
n.o = e
m.p = a
m.v = h
e.u = h
e.o = n
a.p = m
a.v = n
i.p = a
i.v = e
l.u = e
l.o = b
b.u = l
b.o = l
h.u = b
h.o = l
assert i.p.v.o.o.o.o.u.u.txt == "b"