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

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

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

n = A("n")
b = B("b")
a = C("a")

n.q = a
n.v = a
n.z = a
b.z = a
b.s = a
a.u = b
a.z = b
a.s = b
assert b.s.z.s.txt == "
class A:
    def __init__(self, txt: str):
        self.q: C = None
        self.v: C = None
        self.z: C = None
        self.txt = txt

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

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

n = A("n")
b = B("b")
a = C("a")

n.q = a
n.v = a
n.z = a
b.z = a
b.s = a
a.u = b
a.z = b
a.s = b
assert b.s.z.s.txt == "a"