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

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

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

i = A("i")
n = B("n")
m = C("m")

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

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

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

i = A("i")
n = B("n")
m = C("m")

i.w = m
i.z = n
i.q = n
n.t = m
m.u = i
m.w = i
assert m.u.z.t.txt == "m"