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