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

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

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

h = A("h")
f = B("f")
c = C("c")
i = B("i")
l = C("l")
n = B("n")
a = A("a")
d = A("d")

h.p = a
f.y = n
c.s = a
i.y = f
l.s = a
n.y = i
a.p = d
d.p = a
assert h.p.p.p.p.txt == "
class A:
    def __init__(self, txt: str):
        self.p: A = None
        self.txt = txt

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

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

h = A("h")
f = B("f")
c = C("c")
i = B("i")
l = C("l")
n = B("n")
a = A("a")
d = A("d")

h.p = a
f.y = n
c.s = a
i.y = f
l.s = a
n.y = i
a.p = d
d.p = a
assert h.p.p.p.p.txt == "d"