In reply to Gerard.

The expression r3 = mod(abs(a), q) is not equivalent to r2, so it's not the answer that I want.