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

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

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

h = A("h")
b = B("b")
k = C("k")

h.q = b
h.v = b
h.z = b
b.p = h
b.z = h
b.s = k
k.v = h
k.w = h
k.u = b
assert b.s.v.z.txt == "
class A:
    def __init__(self, txt: str):
        self.q: B = None
        self.v: B = None
        self.z: B = None
        self.txt = txt

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

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

h = A("h")
b = B("b")
k = C("k")

h.q = b
h.v = b
h.z = b
b.p = h
b.z = h
b.s = k
k.v = h
k.w = h
k.u = b
assert b.s.v.z.txt == "b"