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

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

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

e.p = a
n.r = f
k.p = j
g.r = j
j.p = f
f.p = j
a.p = f
i.p = a
l.r = f
assert f.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.r: A = None
        self.txt = txt

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

e.p = a
n.r = f
k.p = j
g.r = j
j.p = f
f.p = j
a.p = f
i.p = a
l.r = f
assert f.p.p.p.txt == "j"