// better modulo that gives positive numbers always static int mod(int n, int m) { ret (n % m + m) % m; }