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

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

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

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

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

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

e.p = n
i.t = d
i.u = n
n.p = f
d.t = i
d.u = n
b.p = h
a.p = n
f.p = k
k.p = f
h.p = k
assert k.p.p.p.txt == "f"