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

class B:
    def __init__(self, txt: str):
        self.z: D = None
        self.p: C = None
        self.x: C = None
        self.u: E = None
        self.txt = txt

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

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

class E:
    def __init__(self, txt: str):
        self.p: A = None
        self.r: A = None
        self.s: E = None
        self.txt = txt

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

c.w = m
c.x = m
c.z = h
m.z = g
m.p = a
m.x = a
m.u = n
a.t = g
a.o = m
a.s = c
g.w = m
g.t = m
g.r = c
h.p = c
h.r = c
h.s = n
n.p = c
n.r = c
n.s = h
assert a.o.u.p.z.s.s.txt == "
class A:
    def __init__(self, txt: str):
        self.w: B = None
        self.z: E = None
        self.x: B = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.z: D = None
        self.p: C = None
        self.x: C = None
        self.u: E = None
        self.txt = txt

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

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

class E:
    def __init__(self, txt: str):
        self.p: A = None
        self.r: A = None
        self.s: E = None
        self.txt = txt

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

c.w = m
c.x = m
c.z = h
m.z = g
m.p = a
m.x = a
m.u = n
a.t = g
a.o = m
a.s = c
g.w = m
g.t = m
g.r = c
h.p = c
h.r = c
h.s = n
n.p = c
n.r = c
n.s = h
assert a.o.u.p.z.s.s.txt == "h"