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

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

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

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

h.q = i
h.y = a
i.p = a
i.z = a
a.p = h
a.w = i
assert h.y.p.y.txt == "
class A:
    def __init__(self, txt: str):
        self.q: B = None
        self.y: C = None
        self.txt = txt

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

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

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

h.q = i
h.y = a
i.p = a
i.z = a
a.p = h
a.w = i
assert h.y.p.y.txt == "a"