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

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

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

n = A("n")
j = B("j")
i = C("i")
e = A("e")
a = C("a")
f = A("f")
h = C("h")
b = A("b")

n.s = j
j.p = n
i.t = h
e.s = j
a.t = i
f.s = j
h.t = a
b.s = j
assert n.s.p.s.p.s.p.s.p.txt == "
class A:
    def __init__(self, txt: str):
        self.s: B = None
        self.txt = txt

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

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

n = A("n")
j = B("j")
i = C("i")
e = A("e")
a = C("a")
f = A("f")
h = C("h")
b = A("b")

n.s = j
j.p = n
i.t = h
e.s = j
a.t = i
f.s = j
h.t = a
b.s = j
assert n.s.p.s.p.s.p.s.p.txt == "n"