int quick_pow(int a, int n) { int ans = 1; while (n) { if (n & 1) { ans = (long long )ans * a % inf; } n >>= 1; a = (long long ) a * a % inf; } return ans; }