12345678910int power_mod(int a, int b, int mod){ int res = 1; a = a % mod; while (b) { if (b & 1) res = (res % mod * a % mod) % mod; b >>= 1; a = (a % mod * a % mod) % mod; } return res;}