class A:
    def __init__(self, txt: str):
        self.w: C = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.r: A = None
        self.z: C = None
        self.y: D = None
        self.p: D = None
        self.w: E = None
        self.txt = txt

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

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

class E:
    def __init__(self, txt: str):
        self.s: C = None
        self.r: D = None
        self.q: D = None
        self.txt = txt

n = A("n")
d = B("d")
m = C("m")
l = D("l")
e = E("e")
a = A("a")
h = A("h")
k = D("k")

n.w = m
d.r = h
d.z = m
d.y = l
d.p = k
d.w = e
m.y = d
l.o = m
l.q = d
l.r = d
l.w = h
e.s = m
e.r = k
e.q = k
a.w = m
h.w = m
k.o = m
k.q = d
k.r = d
k.w = h
assert k.w.w.y.p.o.txt == "
class A:
    def __init__(self, txt: str):
        self.w: C = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.r: A = None
        self.z: C = None
        self.y: D = None
        self.p: D = None
        self.w: E = None
        self.txt = txt

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

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

class E:
    def __init__(self, txt: str):
        self.s: C = None
        self.r: D = None
        self.q: D = None
        self.txt = txt

n = A("n")
d = B("d")
m = C("m")
l = D("l")
e = E("e")
a = A("a")
h = A("h")
k = D("k")

n.w = m
d.r = h
d.z = m
d.y = l
d.p = k
d.w = e
m.y = d
l.o = m
l.q = d
l.r = d
l.w = h
e.s = m
e.r = k
e.q = k
a.w = m
h.w = m
k.o = m
k.q = d
k.r = d
k.w = h
assert k.w.w.y.p.o.txt == "m"