#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 mult(vector& v,vector& v2) { int i,j; int M=v.size(); vector t(2*M,0); FOR(i,M) FOR(j,M) t[i+j] += v[i]*v2[j] % mo; for(i=2*M-1;i>=M;i--) { ll ti=t[i]%mo; if(ti) for(j=1;j<=M;j++) t[i-j] += single[j]*ti % mo; } FOR(j,M) ((t[j]%=mo)+=mo)%=mo; t.resize(M); return t; } 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-1;y>=0;y--) { FOR(i,y*13+1) if(dp[0][y][i]) { for(r=1;r+y<=P;r++) (dp[0][y+r][i+r*AA[x]] += dp[0][y][i])%=mo; } } for(y=C-1;y>=0;y--) { FOR(i,y*12+1) if(dp[1][y][i]) { for(r=1;r+y<=C;r++) (dp[1][y+r][i+r*B[x]] += dp[1][y][i])%=mo; } } } FOR(x,700) FOR(y,700) (single[x+y] += dp[0][P][x]*dp[1][C][y])%=mo; M=P*13+C*12; 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; } ll tot=0; if(N<=2*M) { for(ll v=max(0LL,N-M);v=N) tot += dp2[v]*single[x]%mo; tot %= mo; } } else { ll vv=N-M; vector R(M,0),V(M,0); R[0]=V[1]=1; while(vv) { if(vv%2) R=mult(R,V); V=mult(V,V); vv/=2; } for(ll v=max(0LL,N-M);v=N) tot += pat*single[x]%mo; tot %= mo; } } cout<