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

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

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

n.s = i
k.p = i
e.p = i
i.s = n
assert k.p.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: A = None
        self.txt = txt

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

n.s = i
k.p = i
e.p = i
i.s = n
assert k.p.s.s.s.txt == "n"