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

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

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

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

g.q = n
j.q = g
j.t = n
n.s = g
n.z = g
n.u = g
assert g.q.s.q.txt == "
class A:
    def __init__(self, txt: str):
        self.q: C = None
        self.txt = txt

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

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

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

g.q = n
j.q = g
j.t = n
n.s = g
n.z = g
n.u = g
assert g.q.s.q.txt == "n"