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

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

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

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

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

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

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

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

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