class A:
    def __init__(self, txt: str):
        self.z: D = None
        self.o: E = None
        self.txt = txt

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

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

class D:
    def __init__(self, txt: str):
        self.o: A = None
        self.u: E = None
        self.r: E = None
        self.v: C = None
        self.p: C = None
        self.txt = txt

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

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

n.z = l
n.o = d
g.u = m
g.v = d
m.o = d
m.s = d
m.p = g
m.r = g
l.o = n
l.u = d
l.r = d
l.v = m
l.p = m
d.p = l
h.z = l
h.o = d
assert m.o.p.u.p.o.txt == "
class A:
    def __init__(self, txt: str):
        self.z: D = None
        self.o: E = None
        self.txt = txt

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

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

class D:
    def __init__(self, txt: str):
        self.o: A = None
        self.u: E = None
        self.r: E = None
        self.v: C = None
        self.p: C = None
        self.txt = txt

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

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

n.z = l
n.o = d
g.u = m
g.v = d
m.o = d
m.s = d
m.p = g
m.r = g
l.o = n
l.u = d
l.r = d
l.v = m
l.p = m
d.p = l
h.z = l
h.o = d
assert m.o.p.u.p.o.txt == "n"