
Golden Recurrence
Consider the following recurrence relation: \begin{align} a_0 &= \frac{\sqrt 5 + 1}2\\ a_{n+1} &= \dfrac{a_n(a_n^4 + 10a_n^2 + 5)}{5a_n^4 + 10a_n^2 + 1} \end{align}
Note that $a_0$ is the golden ratio.
$a_n$ can always be written in the form $\dfrac{p_n\sqrt{5}+1}{q_n}$, where $p_n$ and $q_n$ are positive integers.
Let $s(n)=p_n^5+q_n^5$. So, $s(0)=1^5+2^5=33$.
The Fibonacci sequence is defined as: $F_1=1$, $F_2=1$, $F_n=F_{n-1}+F_{n-2}$ for $n > 2$.
Define $\displaystyle S(m)=\sum_{i=2}^{m}s(F_i)$.
Find $S(1618034)$. Submit your answer modulo $398874989$.