#include using namespace std; typedef signed long long ll; #undef _P #define _P(...) (void)printf(__VA_ARGS__) #define FOR(x,to) for(x=0;x P; static ll ext_gcd(ll p,ll q,ll& x, ll& y) { // get px+qy=gcd(p,q) if(q==0) return x=1,y=0,p; ll g=ext_gcd(q,p%q,y,x); y-=p/q*x; return g; } static ll inv(ll p,ll q) { // return (1/p)%q ( p,q is co-prime) static map,ll> MM; if(MM.count(make_pair(p,q))) return MM[make_pair(p,q)]; ll xx,yy,g=ext_gcd(p,q,xx,yy); if(xx<0) xx+=q, yy-=p; return MM[make_pair(p,q)] = xx; } static ll modpow(ll a, ll n, ll mo) { ll r=1; while(n) r=(n%2)?(r*a)%mo:r,a=a*a%mo,n>>=1; return r; } static vector FMT(vector v, ll mo, bool rev=false) { // v.size()=2^k, mo = 2^22*k+1, int i,j,k,n=v.size(); // n=2^k; ll pf=modpow(3,(mo-1)/n,mo); if(rev) pf=modpow(pf,mo-2,mo); for(i=0,j=1;j>1;k>(i^=k);k>>=1); if(i>j) swap(v[i],v[j]); } /* for(int m=2; m<=n; m*=2) { ll ba=modpow(pf,n/m,mo); ll w=1; FOR(i,m/2) { for(int j1=i,j2=i+m/2;j2=mo) t2%=mo; v[j1]=t1+t2, v[j2]=t1-t2; if(v[j1]>=mo) v[j1]-=mo; if(v[j2]<0) v[j2]+=mo; } w*=ba; if(w>=mo) w%=mo; } } */ if(rev) { ll rn=modpow(n,mo-2,mo); FOR(i,n) v[i]=v[i]*rn%mo; } return v; } static ll CRT_garner(vector > V,ll mo=1000000007) { int x,y,N=V.size(); FOR(y,N) FOR(x,y) { ll k=V[y].second-V[x].second; if(k<0) k+=V[y].first; V[y].second = k*inv(V[x].first,V[y].first)%V[y].first; } ll ret=0; for(x=N-1;x>=0;x--) ret = (ret*V[x].first+V[x].second)%mo; return ret; } static vector convol_sub(vector a,vector b, int mo,int t=99999999) { // mo = 2^k+1 int i,n=1; while(n convol(vector& a,vector& b, ll mo,int t=99999999) { ll mop[3]={0xA000001,0x1C000001,0x49000001}; auto x = convol_sub(a,b,mop[0],t); auto y = convol_sub(a,b,mop[1],t); auto z = convol_sub(a,b,mop[2],t); t=min(t,(int)x.size()); vector R(t); vector > P{{mop[0],0},{mop[1],0},{mop[2],0}}; for(int i=0;i mult(vector& v,vector& v2,vector& D,vector& id, ll mo) { int k=v.size(),i; vector res(k,0); vector beta=convol(v,v2,mo); for(i=k-1;i q=convol(beta,id,mo,k-1); q=convol(q,D,mo); for(i=k-1;i getid(vector D, ll mo) { int t=1,k=D.size(); vector id(1,1); while(t<=k) { t=min(2*t,k+1); vector D2=D; D2.resize(t); vector cur=convol(D2,id,mo,t); cur.resize(t); cur[0]+=2; id=convol(id,cur,mo,t); id.resize(t); } return id; } void calc(ll N, vector D, ll mo) { int n=D.size(); vector p(n,0),v(n,0); p[0]=v[1]=1; reverse(ALL(D));reverse(ALL(p));reverse(ALL(v)); D.insert(D.begin(),mo-1); vector id=getid(D,mo); while(N) { if(N%2) p=mult(p,v,D,id,mo); v=mult(v,v,D,id,mo); N/=2; } reverse(ALL(p)); P=p; } ll calc(ll N, vector A, vector D, ll mo) { // A_K=A0*D0+A1*D1+A2*D2..+A_K-1*D_K-1 return A_N int i;ll ret=0; calc(N,D,mo); FOR(i,A.size()) ret += A[i]*P[i]%mo; return ret%mo; } }; ll N; int P,C,M; int A[6]={2,3,5,7,11,13}; int B[6]={4,6,8,9,10,12}; ll dp[2][400][4000]; ll dp2[8000]; ll single[8010]; ll mo=1000000007; void solve() { int i,j,k,l,r,x,y; string s; cin>>N>>P>>C; dp[0][0][0]=dp[1][0][0]=1; FOR(x,6) FOR(y,P) FOR(i,y*13+1) if((dp[0][y+1][i+A[x]] += dp[0][y][i])>=mo) dp[0][y+1][i+A[x]]-=mo; FOR(x,6) FOR(y,C) FOR(i,y*12+1) if((dp[1][y+1][i+B[x]] += dp[1][y][i])>=mo) dp[1][y+1][i+B[x]]-=mo; FOR(x,300*13+1) if(dp[0][P][x]) FOR(y,300*12+1) (single[x+y] += dp[0][P][x]*dp[1][C][y])%=mo; M=P*13+C*12; ll tot=0; if(N<=2*M) { dp2[0]=1; for(i=1;i<=2*M+2;i++) { FOR(x,M+1) if(i>=x) dp2[i] += dp2[i-x]*single[x]%mo; dp2[i] %= mo; } for(ll v=max(0LL,N-M);v=N) tot += dp2[v]*single[x]%mo; tot %= mo; } } else { Kitamasa_fast kf; vector A(M,1),V(M,0); FOR(i,M) V[i]=single[M-i]; tot = kf.calc(N+M-1,A,V,mo); } cout<