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

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

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

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

k.u = e
k.r = a
i.y = e
i.p = k
i.z = a
e.w = i
e.s = a
e.q = k
a.y = e
a.p = k
a.z = i
assert k.u.w.y.q.txt == "
class A:
    def __init__(self, txt: str):
        self.u: C = None
        self.r: B = None
        self.txt = txt

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

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

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

k.u = e
k.r = a
i.y = e
i.p = k
i.z = a
e.w = i
e.s = a
e.q = k
a.y = e
a.p = k
a.z = i
assert k.u.w.y.q.txt == "k"