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

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

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

h = A("h")
m = B("m")
c = C("c")
d = A("d")

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

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

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

h = A("h")
m = B("m")
c = C("c")
d = A("d")

h.v = c
h.u = m
m.q = c
c.s = m
d.v = c
d.u = m
assert d.v.s.q.s.txt == "m"