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

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

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

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

m.v = c
m.w = g
f.w = k
a.s = h
a.w = n
g.v = l
g.w = m
l.w = n
h.s = k
h.w = n
n.s = k
n.w = a
c.w = k
k.s = n
k.w = n
assert h.s.w.s.w.w.w.w.s.txt == "
class A:
    def __init__(self, txt: str):
        self.v: B = None
        self.w: A = None
        self.txt = txt

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

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

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

m.v = c
m.w = g
f.w = k
a.s = h
a.w = n
g.v = l
g.w = m
l.w = n
h.s = k
h.w = n
n.s = k
n.w = a
c.w = k
k.s = n
k.w = n
assert h.s.w.s.w.w.w.w.s.txt == "h"