#include using namespace std; typedef vector VI; typedef vector VVI; typedef vector VS; typedef pair PII; typedef long long LL; typedef pair PLL; #define ALL(a) (a).begin(),(a).end() #define RALL(a) (a).rbegin(), (a).rend() #define PB push_back #define EB emplace_back #define MP make_pair #define SZ(a) int((a).size()) #define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i) #define EXIST(s,e) ((s).find(e)!=(s).end()) #define SORT(c) sort((c).begin(),(c).end()) #define FOR(i,a,b) for(int i=(a);i<(b);++i) #define REP(i,n) FOR(i,0,n) #define FF first #define SS second template istream& operator>>(istream& is, pair& p){ return is >> p.FF >> p.SS; } const double EPS = 1e-10; const double PI = acos(-1.0); const LL MOD = 1e9+7; void dfs(VI& xs, map& res, int n, int i=0, int acc = 0){ if(n == 0){ res[acc]++; return; } if(i >= 6) return; for(int m=0;m<=n;++m) dfs(xs, res, n-m, i+1, acc+xs[i]*m); } typedef vector Col; typedef vector Matrix; Matrix mul(const Matrix& A, const Matrix& B){ const int R = A.size(), C = B[0].size(), sz = B.size(); Matrix AB(R, Col(C)); for(int i=0;i0){ if(n&1) p = mul(p, w); w = mul(w, w); n >>= 1; } return p; } int main(){ cin.tie(0); ios_base::sync_with_stdio(false); VI ps{2,3,5,7,11,13}; VI qs{4,6,8,9,10,12}; LL N, P, C; cin >> N >> P >> C; map memo1, memo2; dfs(ps, memo1, P); dfs(qs, memo2, C); map pat; for(auto& p1: memo1) for(auto& p2: memo2) pat[p1.FF+p2.FF] += p1.SS * p2.SS; int D = 13*P + 12*C; Matrix p(D, Col(D)); REP(i,D-1) p[i][i+1] = 1; for(auto& x: pat) p[x.FF-1][0] = x.SS; p = powA(p, N); LL ans = 0; REP(i,D) (ans += p[i][0]) %= MOD; cout << ans << endl; return 0; }