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

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

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

n.y = c
i.u = l
i.y = h
h.u = n
h.y = m
a.u = n
a.y = c
b.y = m
m.u = n
m.y = i
c.u = b
c.y = h
l.y = a
assert a.y.u.y.y.u.y.y.u.txt == "
class A:
    def __init__(self, txt: str):
        self.y: B = None
        self.txt = txt

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

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

n.y = c
i.u = l
i.y = h
h.u = n
h.y = m
a.u = n
a.y = c
b.y = m
m.u = n
m.y = i
c.u = b
c.y = h
l.y = a
assert a.y.u.y.y.u.y.y.u.txt == "b"