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

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

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

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

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

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

n.u = f
f.p = k
m.u = f
j.u = e
e.p = f
l.u = f
k.p = e
a.u = f
h.u = f
assert h.u.p.p.p.txt == "f"