typedef long long ll;
//O(1)快速乘
inline ll quick_mul(ll x,ll y,ll MOD){
x=x%MOD,y=y%MOD;
return ((x*y-(ll)(((long double)x*y+0.5)/MOD)*MOD)%MOD+MOD)%MOD;
}
//O(log)快速乘
inline ll quick_mul(ll a,ll n,ll MOD){
ll ans=0;
while(n){
if(n&1) ans=(ans+a)%MOD;
a=(a<<1)%MOD;
n>>=1;
}
return ans;
}