Determine the number of pairs of prime numbers $p$ and $q$, both of which are less than $2017,$ such that $p$ divides $q-1$ and $q$ divides $p^3-1$.
If $p = 2$, then $q = 7$ and if $q = 2$, there are no solutions. Now suppose that $p,q > 2$. We have from the given that $q \equiv 1 \pmod{p}$ and $p^3 \equiv 1 \pmod{q}$. Thus, $q = 1+pk$ where $k$ is even and $p^3 = 1+qm$, where $m$ is even. Therefore, $p^3 = 1+m(1+pk)$ and so $m = \dfrac{p^3-1}{pk+1}$.
I didn't see how to continue from here.