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

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

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

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

h.o = g
h.t = f
h.p = i
g.s = k
g.p = f
k.p = a
a.o = g
a.t = g
a.p = i
f.s = k
f.p = g
i.p = a
assert f.s.p.p.p.p.txt == "
class A:
    def __init__(self, txt: str):
        self.o: B = None
        self.t: B = None
        self.p: C = None
        self.txt = txt

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

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

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

h.o = g
h.t = f
h.p = i
g.s = k
g.p = f
k.p = a
a.o = g
a.t = g
a.p = i
f.s = k
f.p = g
i.p = a
assert f.s.p.p.p.p.txt == "i"