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

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

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

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

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

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

e.p = n
e.t = k
g.o = h
n.o = k
i.o = e
f.p = l
f.t = h
m.o = h
l.o = k
k.p = m
k.t = f
h.p = i
h.t = a
a.p = l
a.t = k
assert k.t.t.p.o.t.t.p.txt == "l"