Smallest positive integer r such that $8^{17} \equiv r \pmod {97}$

I want find out the Smallest positive integer r such that $8^{17} \equiv r \pmod{97}$.

Fermat's theorem only tells us $8^{96} \equiv 1 \pmod{97}.$

How can I proceed. Any hint will be appreciated.

• Hint: $8^{16}=2^{48}\equiv \pm 1\pmod{97}$. When is $2^{(p-1)/2}\equiv 1\pmod p$? – Thomas Andrews May 5 '16 at 3:02
We have that $2$ is a quadratic residue $\pmod p$ when $p \equiv \pm 1 \pmod 8$. In this case, $97 \equiv 1 \pmod 8$, ensuring that $2$ is a quadratic residue.
By Euler's Criterion, we have that $8^{16}=2^{48} \equiv 1 \pmod {97}$. Thus, $8^{17} \equiv 8 \pmod {97}$.