#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>=1; } return r; } 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,90) if(dp[0][y][i]) { for(r=1;r+y<=P;r++) (dp[0][y+r][i+r*A[x]] += dp[0][y][i])%=mo; } } for(y=C-1;y>=0;y--) { FOR(i,90) 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,90) FOR(y,90) single[x+y] += dp[0][P][x]*dp[1][C][y]; int M=P*13+C*12; int K=M+1; Mat mm; ZERO(mm.v); FOR(i,M) mm.v[i][i+1]=1; for(i=1;i<=M;i++) mm.v[M][M+1-i]=single[i]; Mat m2=powmat(N-1,mm,K); ll tot=0; FOR(i,K) FOR(x,K) if(N-1-(M-i)+x>=N) tot += m2.v[i][M]*single[x]%mo; cout<