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

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

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

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

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

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

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

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

n.w = g
n.z = g
n.q = g
g.z = n
g.r = n
g.t = i
i.w = n
i.r = g
assert g.t.w.z.txt == "g"