I came across this exercise in Rosen Discrete Mathematics and its applications and even after spending an hour plus googling I couldn't find an answer that could explain how this question is to be done. I saw somewhere that a certain theorem is used, but I'm not sure how it is applied.
The answer is: $((-4)^3 \mod 23)^2\mod31=(-64\mod23)^2\mod31=25$
Possibly useful theorem:
If $a \equiv b\mod m, c\equiv d\mod m$ then $ac=bd(\mod m)$
My question: I'm concerned with how I can get from $19^3$ to $(-4)^3$.