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

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

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

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

n.w = k
n.t = e
n.r = g
m.w = k
m.s = k
k.o = n
k.s = g
e.w = k
e.t = g
e.r = g
g.w = k
g.t = n
g.r = n
l.w = k
l.s = k
a.w = k
a.s = k
assert m.w.o.t.r.w.s.txt == "
class A:
    def __init__(self, txt: str):
        self.w: C = None
        self.t: A = None
        self.r: A = None
        self.txt = txt

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

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

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

n.w = k
n.t = e
n.r = g
m.w = k
m.s = k
k.o = n
k.s = g
e.w = k
e.t = g
e.r = g
g.w = k
g.t = n
g.r = n
l.w = k
l.s = k
a.w = k
a.s = k
assert m.w.o.t.r.w.s.txt == "g"