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

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

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

a = A("a")
k = B("k")
i = C("i")
g = B("g")
e = B("e")
n = C("n")
l = C("l")
h = B("h")
f = C("f")

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

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

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

a = A("a")
k = B("k")
i = C("i")
g = B("g")
e = B("e")
n = C("n")
l = C("l")
h = B("h")
f = C("f")

a.s = i
a.v = h
k.t = i
i.w = k
g.t = i
e.t = n
n.w = h
l.w = h
h.t = i
f.w = e
assert n.w.t.w.t.w.t.w.t.txt == "i"