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

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

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

a = A("a")
h = B("h")
c = C("c")

a.z = h
a.w = h
a.s = c
h.s = c
h.w = c
h.z = c
c.u = h
c.q = a
assert c.q.s.u.txt == "
class A:
    def __init__(self, txt: str):
        self.z: B = None
        self.s: C = None
        self.w: B = None
        self.txt = txt

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

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

a = A("a")
h = B("h")
c = C("c")

a.z = h
a.w = h
a.s = c
h.s = c
h.w = c
h.z = c
c.u = h
c.q = a
assert c.q.s.u.txt == "h"