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

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

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

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

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

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

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

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

m.v = h
m.p = e
m.s = b
a.v = m
h.u = m
h.q = m
h.p = e
b.v = m
e.v = m
assert h.q.p.v.s.v.txt == "m"