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

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

e = A("e")
l = B("l")
n = A("n")
a = B("a")
g = A("g")
j = B("j")
i = B("i")
m = A("m")
b = B("b")
f = A("f")

e.p = m
e.y = b
l.r = m
l.t = b
n.p = g
n.y = i
a.r = m
a.t = i
g.p = n
g.y = a
j.r = n
j.t = b
i.r = g
i.t = a
m.p = n
m.y = l
b.r = e
b.t = j
f.p = n
f.y = a
assert m.p.p.p.p.y.txt == "
class A:
    def __init__(self, txt: str):
        self.p: A = None
        self.y: B = None
        self.txt = txt

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

e = A("e")
l = B("l")
n = A("n")
a = B("a")
g = A("g")
j = B("j")
i = B("i")
m = A("m")
b = B("b")
f = A("f")

e.p = m
e.y = b
l.r = m
l.t = b
n.p = g
n.y = i
a.r = m
a.t = i
g.p = n
g.y = a
j.r = n
j.t = b
i.r = g
i.t = a
m.p = n
m.y = l
b.r = e
b.t = j
f.p = n
f.y = a
assert m.p.p.p.p.y.txt == "a"