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

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

e = A("e")
n = B("n")
i = B("i")
a = A("a")

e.s = a
n.p = i
n.y = a
i.p = n
i.y = a
a.s = e
assert e.s.s.s.s.txt == "
class A:
    def __init__(self, txt: str):
        self.s: A = None
        self.txt = txt

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

e = A("e")
n = B("n")
i = B("i")
a = A("a")

e.s = a
n.p = i
n.y = a
i.p = n
i.y = a
a.s = e
assert e.s.s.s.s.txt == "e"