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

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

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

n = A("n")
k = B("k")
g = C("g")

n.z = g
n.o = g
k.p = g
k.t = n
g.y = n
g.v = n
g.z = k
assert k.p.z.t.txt == "
class A:
    def __init__(self, txt: str):
        self.z: C = None
        self.o: C = None
        self.txt = txt

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

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

n = A("n")
k = B("k")
g = C("g")

n.z = g
n.o = g
k.p = g
k.t = n
g.y = n
g.v = n
g.z = k
assert k.p.z.t.txt == "n"