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

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

e = A("e")
j = B("j")
n = A("n")
i = B("i")
l = B("l")

e.p = j
j.s = i
j.z = e
n.p = l
i.s = j
i.z = e
l.s = j
l.z = n
assert l.z.p.z.p.txt == "
class A:
    def __init__(self, txt: str):
        self.p: B = None
        self.txt = txt

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

e = A("e")
j = B("j")
n = A("n")
i = B("i")
l = B("l")

e.p = j
j.s = i
j.z = e
n.p = l
i.s = j
i.z = e
l.s = j
l.z = n
assert l.z.p.z.p.txt == "l"