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

class B:
    def __init__(self, txt: str):
        self.w: B = None
        self.u: A = None
        self.q: C = None
        self.txt = txt

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

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

n.z = i
n.v = c
k.w = c
k.u = n
k.q = i
i.r = c
c.w = k
c.u = n
c.q = i
assert c.u.z.r.txt == "
class A:
    def __init__(self, txt: str):
        self.z: C = None
        self.v: B = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.w: B = None
        self.u: A = None
        self.q: C = None
        self.txt = txt

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

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

n.z = i
n.v = c
k.w = c
k.u = n
k.q = i
i.r = c
c.w = k
c.u = n
c.q = i
assert c.u.z.r.txt == "c"