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

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

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

e = A("e")
f = B("f")
j = C("j")
n = A("n")

e.z = n
e.p = j
f.o = j
j.z = f
j.v = f
j.p = e
n.z = e
n.p = j
assert e.z.p.z.txt == "
class A:
    def __init__(self, txt: str):
        self.z: A = None
        self.p: C = None
        self.txt = txt

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

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

e = A("e")
f = B("f")
j = C("j")
n = A("n")

e.z = n
e.p = j
f.o = j
j.z = f
j.v = f
j.p = e
n.z = e
n.p = j
assert e.z.p.z.txt == "f"