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

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

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

d = A("d")
n = B("n")
m = C("m")
k = B("k")
b = A("b")
c = A("c")
a = B("a")
h = B("h")
f = B("f")
i = C("i")

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

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

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

d = A("d")
n = B("n")
m = C("m")
k = B("k")
b = A("b")
c = A("c")
a = B("a")
h = B("h")
f = B("f")
i = C("i")

d.s = a
n.s = h
n.w = a
n.p = a
m.q = d
m.y = i
k.s = h
k.w = a
k.p = n
b.s = a
c.s = h
a.s = n
a.w = f
a.p = k
h.s = n
h.w = k
h.p = k
f.s = a
f.w = a
f.p = a
i.q = c
i.y = m
assert n.s.s.w.w.s.p.w.w.txt == "f"