Calculates 'x' modulo 'mod', takes to consideration sign of x, i.e.
Calculates 'x' modulo 'mod', takes to consideration sign of x, i.e. if 'x' is negative, than 'x' % 'mod' is negative too so function return (x % mod) + mod in that case.
Firscher-Yates shuffle.
Firscher-Yates shuffle.