1 ll q_mult(ll a, ll b ,ll mod){ 2 ll ans = 0; 3 while(b){ 4 if(b&1) 5 ans = (ans + a)%mod; 6 a = (a<<1) % mod; 7 b>>=1; 8 } 9 return ans; 10 }