I am revisiting Euler's criterion, so I bumped into the following statement which I don't know how to prove.
Let $p$ be some prime number and $a \in \mathbb{Z}$.
How to prove that for every $x \in \{1, 2, ..., p - 1\}$ there exist exactly one $y \in \{1, 2, ..., p - 1\}$ such that $xy \equiv a \pmod p$? (Of course, "exatcly one" in terms of modulo $p$.)
How to generalise this when $p$ is not a prime number?