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

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

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

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

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

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

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

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

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

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

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