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

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

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

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

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

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

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

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

m.y = h
a.s = m
a.v = m
a.u = m
h.v = a
h.q = a
assert a.s.y.v.txt == "a"