#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; } ll getpat(ll v) { } 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(x,6) { 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; } } } int ama=0,bma=0; FOR(i,90) if(dp[0][P][i]) ama=i; FOR(i,90) if(dp[1][C][i]) bma=i; FOR(x,90) FOR(y,90) single[x+y] += dp[0][P][x]*dp[1][C][y] % mo; FOR(x,200) single[x] %= mo; dp2[0]=1; for(i=1;i<=1000;i++) { FOR(x,ama+bma+1) if(i>=x) dp2[i] += dp2[i-x]*single[x]%mo; dp2[i] %= mo; } ll tot=0; if(N<=1000) { FOR(i,N) { FOR(x,ama+bma+1) if(i+x>=N) tot += dp2[i] * single[x] % mo; } } else { assert(0); Mat mm; ZERO(mm.v); FOR(i,ama+bma) mm.v[i+1][i]=1; FOR(i,ama+bma+1) mm.v[0][i]=single[i]; ll v=N-(ama+bma+1); Mat tot=powmat(v,mm,ama+bma+1); } cout<