Regarding, two set of values for $a,n,x$; refer to your example in answer. There you took one set of values::::Let say $n=3$, we let $q=1$ and $r=0$, that is $x=3$. Let $a=2$, check that $a^{qn}=2^{3}=8 \not\equiv 1 \pmod{n}$
$$2^{x} \pmod{3} \equiv 2^3 \pmod{3} \equiv -1 \pmod{3}$$