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

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

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

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

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

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

i.z = n
i.p = j
l.o = n
l.x = i
j.z = l
j.p = i
n.o = l
n.x = i
assert j.z.x.z.txt == "n"