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

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

b = A("b")
h = B("h")
c = A("c")
n = B("n")
m = B("m")
l = A("l")
f = B("f")
a = A("a")
k = A("k")
e = B("e")

b.t = a
b.p = e
h.u = n
c.t = k
c.p = m
n.u = h
m.u = h
l.t = k
l.p = f
f.u = n
a.t = b
a.p = e
k.t = c
k.p = m
e.u = f
assert k.p.u.u.txt == "
class A:
    def __init__(self, txt: str):
        self.t: A = None
        self.p: B = None
        self.txt = txt

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

b = A("b")
h = B("h")
c = A("c")
n = B("n")
m = B("m")
l = A("l")
f = B("f")
a = A("a")
k = A("k")
e = B("e")

b.t = a
b.p = e
h.u = n
c.t = k
c.p = m
n.u = h
m.u = h
l.t = k
l.p = f
f.u = n
a.t = b
a.p = e
k.t = c
k.p = m
e.u = f
assert k.p.u.u.txt == "n"