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

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

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

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

f.s = e
b.w = f
b.y = h
c.s = k
c.w = h
l.s = f
l.w = n
m.w = k
m.y = n
k.s = a
a.s = f
a.w = m
h.w = k
h.y = m
e.s = k
e.w = h
n.w = k
n.y = m
assert l.w.y.y.y.w.s.s.s.w.w.txt == "
class A:
    def __init__(self, txt: str):
        self.s: C = None
        self.txt = txt

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

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

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

f.s = e
b.w = f
b.y = h
c.s = k
c.w = h
l.s = f
l.w = n
m.w = k
m.y = n
k.s = a
a.s = f
a.w = m
h.w = k
h.y = m
e.s = k
e.w = h
n.w = k
n.y = m
assert l.w.y.y.y.w.s.s.s.w.w.txt == "k"