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

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

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

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

h.w = m
h.t = a
h.s = a
a.y = m
m.q = h
m.w = a
assert m.q.s.y.txt == "
class A:
    def __init__(self, txt: str):
        self.w: C = None
        self.t: B = None
        self.s: B = None
        self.txt = txt

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

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

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

h.w = m
h.t = a
h.s = a
a.y = m
m.q = h
m.w = a
assert m.q.s.y.txt == "m"