Equality of powers of a $2\times2$ matrix over the integers modulo a prime number This is exercise 4 in section 2.6 in Basic Algebra 1 by Nathan Jacobson:

Let $A\in GL_2(\mathbb Z/p\mathbb Z)$ (that is, $A$ is an invertible 2 x 2 matrix with entries in $\mathbb Z/p\mathbb Z$, $p$ prime).
Show that $A^q = 1$ if $q = (p^2 - 1)(p^2 - p)$.
Show also that $A^{q + 2} = A^2$ for every $A \in M_2(\mathbb Z/p\mathbb Z)$ (the ring of matrices over $\mathbb Z/p\mathbb Z$).

The first part follows from the fact that $GL_2(\mathbb Z/p\mathbb Z)$ is a finite group of order $q$.
I'm having trouble with the second part and would appreciate any hint or answer. Thank you.

Hint: $A$ has either two distinct eigenvalues in $\mathbb Z/p\mathbb Z$, or a double eigenvalue in $\mathbb Z/p\mathbb Z$, or two  eigenvalues in $GF(p^2)$ (a quadratic extension of $\mathbb Z/p\mathbb Z$).
