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

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

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

j = A("j")
c = B("c")
n = C("n")
f = A("f")
i = C("i")
m = A("m")
d = C("d")
g = C("g")
k = A("k")
e = A("e")

j.s = n
j.w = c
c.r = e
c.p = n
n.p = g
n.s = c
f.s = d
f.w = c
i.p = d
i.s = c
m.s = i
m.w = c
d.p = g
d.s = c
g.p = d
g.s = c
k.s = g
k.w = c
e.s = d
e.w = c
assert n.p.p.s.p.txt == "
class A:
    def __init__(self, txt: str):
        self.s: C = None
        self.w: B = None
        self.txt = txt

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

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

j = A("j")
c = B("c")
n = C("n")
f = A("f")
i = C("i")
m = A("m")
d = C("d")
g = C("g")
k = A("k")
e = A("e")

j.s = n
j.w = c
c.r = e
c.p = n
n.p = g
n.s = c
f.s = d
f.w = c
i.p = d
i.s = c
m.s = i
m.w = c
d.p = g
d.s = c
g.p = d
g.s = c
k.s = g
k.w = c
e.s = d
e.w = c
assert n.p.p.s.p.txt == "n"