ll fac[MAX];//因子
ll p[109];
ll lucas[109];
ll n,m,k;
ll modpow(ll a,ll b,ll mod)//a^b%mod
{
ll ret = 1;
while(b)
{
if(b&1) ret = (ret*a)%mod;
a = (a*a)% mod;
b>>=1;
}
return ret;
}
ll modmul(ll a,ll b,ll mod)//a*b%mod;
{
ll ret = 0;
while(b)
{
if(b&1) ret = (ret + a)%mod;
a = (a + a)% mod;
b>>=1;
}
return ret;
}
ll getFactor(ll p)//求因子
{
fac[0] = 1;
for(int i = 1;i<=p;i++)
{
fac[i] = (fac[i - 1]*i)%p;
}
}
ll Lucas(ll n,ll m,ll p)//大组合数取余
{
ll ret = 1;
while(n&&m)
{
ll a = n%p, b = m%p;
if(a<b) return 0;
ret = (ret*fac[a]*modpow(fac[b]*fac[a - b]%p , p - 2, p)) %p;
n/=p;
m/=p;
}
return ret;
}
ll exgcd(ll a,ll b,ll &x,ll &y)//拓展欧几里得
{
if(!b)
{
x = 1 , y = 0;
return a;
}
int ans = exgcd(b , a%b, y , x);
y-=a/b*x;
return ans;
}
ll CRT(ll *a,ll *m,int len)//中国剩余定理
{
ll d,x,y,ret = 0;
ll M = 1;
for(int i = 0;i < len;i++) M*=m[i];
for(int i = 0;i < len;i++)
{
ll w = M/m[i];
d = exgcd(m[i],w,x,y);
ret = (ret + modmul(modmul(y, w, M), a[i], M) ) % M;
}
return (ret + M) % M;
}