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

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

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

i = A("i")
k = B("k")
a = C("a")
l = A("l")

i.o = k
i.z = l
k.s = i
a.p = k
a.v = l
a.s = l
l.o = k
l.z = i
assert a.p.s.o.s.txt == "
class A:
    def __init__(self, txt: str):
        self.o: B = None
        self.z: A = None
        self.txt = txt

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

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

i = A("i")
k = B("k")
a = C("a")
l = A("l")

i.o = k
i.z = l
k.s = i
a.p = k
a.v = l
a.s = l
l.o = k
l.z = i
assert a.p.s.o.s.txt == "i"