function binpow(a, n) { let res = 1; while (n !== 0) { if (n & 1) { res *= a; } a *= a; n >>= 1; } return res; }