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

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

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

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

n.w = g
n.p = l
h.u = m
h.s = g
k.p = m
k.z = g
g.u = k
g.s = h
l.w = h
l.p = d
d.w = g
d.p = l
m.p = k
m.z = h
assert d.w.s.u.p.p.z.txt == "
class A:
    def __init__(self, txt: str):
        self.w: B = None
        self.p: A = None
        self.txt = txt

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

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

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

n.w = g
n.p = l
h.u = m
h.s = g
k.p = m
k.z = g
g.u = k
g.s = h
l.w = h
l.p = d
d.w = g
d.p = l
m.p = k
m.z = h
assert d.w.s.u.p.p.z.txt == "h"