ll f(ll a, ll b,ll c) { ll ans = 0; while (b!=0) { if (b & 1)ans = (ans + a) % c; a = (a << 1) % c; b >>= 1; } return ans; }