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

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

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

n = A("n")
l = B("l")
f = C("f")
k = A("k")
m = C("m")
a = C("a")
g = B("g")
j = C("j")

n.w = a
n.r = l
n.y = g
l.y = g
f.p = n
f.w = j
k.w = f
k.r = g
k.y = l
m.p = n
m.w = a
a.p = k
a.w = m
g.y = l
j.p = n
j.w = m
assert f.w.w.p.r.y.txt == "
class A:
    def __init__(self, txt: str):
        self.w: C = None
        self.r: B = None
        self.y: B = None
        self.txt = txt

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

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

n = A("n")
l = B("l")
f = C("f")
k = A("k")
m = C("m")
a = C("a")
g = B("g")
j = C("j")

n.w = a
n.r = l
n.y = g
l.y = g
f.p = n
f.w = j
k.w = f
k.r = g
k.y = l
m.p = n
m.w = a
a.p = k
a.w = m
g.y = l
j.p = n
j.w = m
assert f.w.w.p.r.y.txt == "g"