This feels like it should be elementary but it came up in my research and I was not able to solve it. Let
We can ask this question for any $p$ and $q$ but,let $p$ and $q$ be primes for simplicity. The sequence $$ ((a^n \text{ mod } p) \text{ mod } q)$$ is periodic. What is its period?
Can you find a characterization in terms of $a,p,q$? Clearly, it depends on the order of $a$ in $p$. If $p$ is less than $q$ the problem is trivial.