class A:
    def __init__(self, txt: str):
        self.u: C = None
        self.z: C = None
        self.s: D = None
        self.v: D = None
        self.p: E = 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.y: B = None
        self.r: B = None
        self.txt = txt

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

class E:
    def __init__(self, txt: str):
        self.w: D = None
        self.x: D = None
        self.txt = txt

m = A("m")
g = B("g")
c = C("c")
h = D("h")
n = E("n")

m.u = c
m.z = c
m.s = h
m.v = h
m.p = n
g.v = m
c.y = g
c.r = g
h.w = c
h.p = n
n.w = h
n.x = h
assert g.v.s.w.r.v.txt == "
class A:
    def __init__(self, txt: str):
        self.u: C = None
        self.z: C = None
        self.s: D = None
        self.v: D = None
        self.p: E = 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.y: B = None
        self.r: B = None
        self.txt = txt

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

class E:
    def __init__(self, txt: str):
        self.w: D = None
        self.x: D = None
        self.txt = txt

m = A("m")
g = B("g")
c = C("c")
h = D("h")
n = E("n")

m.u = c
m.z = c
m.s = h
m.v = h
m.p = n
g.v = m
c.y = g
c.r = g
h.w = c
h.p = n
n.w = h
n.x = h
assert g.v.s.w.r.v.txt == "m"