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

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

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

l.y = n
j.p = n
e.p = n
n.y = l
k.p = l
assert n.y.y.y.txt == "
class A:
    def __init__(self, txt: str):
        self.y: A = None
        self.txt = txt

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

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

l.y = n
j.p = n
e.p = n
n.y = l
k.p = l
assert n.y.y.y.txt == "l"