ll qmul(ll a, ll b, ll c){ a%=c, b%=c; ll w = (ld)a/c*b; ll r = (ull)a*b-(ull)w*c; return r<0?r+c:r; }