I don't understand the exact steps the following statement is using in regards to what is the multiplicative inverse of $13 \mod 40$
One can find a multiplicative inverse of $13$ by observing that:
$13 \cdot 3 = 39 \equiv -1 \mod 40$ (a)
Hence
$13 \cdot (-3) \equiv 1 \mod 40$ (b)
So $-3$ is a multiplicative inverse of $13 \mod 40$
Now I do understand (a).
I also understand that $13 \cdot (-3) = - 39 = -39 + 40 = 1 \equiv 1 \mod 40$ (c)
What is not clear to me is what rule is used so that we switch the multiplication from $3$ to $-3$.
$3$ and $-3$ are not multiplicative inverses $\mod 40$.
Was there some rule I am not aware or was what I described in c used?
I just would like to know if there is a specific rule used that allowed to go from $-1$ to $1$ by changing the sign in the lhs of the mod