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

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

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

class D:
    def __init__(self, txt: str):
        self.u: B = None
        self.txt = txt

n = A("n")
m = B("m")
l = C("l")
h = D("h")
g = D("g")
c = D("c")
a = D("a")
e = B("e")
d = A("d")

n.o = l
n.y = m
n.w = m
n.p = a
m.y = a
l.u = e
h.u = m
g.u = e
c.u = m
a.u = m
e.y = c
d.o = l
d.y = e
d.w = m
d.p = c
assert n.p.u.y.u.y.u.y.u.txt == "
class A:
    def __init__(self, txt: str):
        self.o: C = None
        self.y: B = None
        self.w: B = None
        self.p: D = None
        self.txt = txt

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

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

class D:
    def __init__(self, txt: str):
        self.u: B = None
        self.txt = txt

n = A("n")
m = B("m")
l = C("l")
h = D("h")
g = D("g")
c = D("c")
a = D("a")
e = B("e")
d = A("d")

n.o = l
n.y = m
n.w = m
n.p = a
m.y = a
l.u = e
h.u = m
g.u = e
c.u = m
a.u = m
e.y = c
d.o = l
d.y = e
d.w = m
d.p = c
assert n.p.u.y.u.y.u.y.u.txt == "m"