#include #include #include #include #include #include #include #include using namespace std; #define REP(i,a,b) for(int i=a;i<(int)b;i++) #define rep(i,n) REP(i,0,n) typedef long long ll; int constexpr MOD = 1e9+7; namespace Matrix { typedef vector Vec; typedef vector Mat; Mat operator * (Mat& A, Mat& B) { Mat C(A.size(), Vec(B[0].size())); rep(i, A.size()) rep(k, B.size()) rep(j, B[0].size()) C[i][j] = (C[i][j] + A[i][k] * B[k][j]) % MOD; return C; } void operator *= (Mat& A, Mat& B) { A = A*B; } Mat operator ^ (Mat& A, ll n) { Mat B(A.size(), Vec(A.size())); rep(i, A.size()) { B[i][i] = 1; } while(n > 0) { if(n & 1) { B *= A; } A *= A; n >>= 1; } return B; } } int constexpr P[] = {2,3,5,7,11,13}, C[] = {4,6,8,9,10,12}; int main() { ll N; int p, c; cin >> N >> p >> c; int dpP[6][13*5+1] = {}; dpP[0][0] = 1; rep(i, 6) rep(j, p+1) rep(k, 13*j+1) { dpP[j+1][k+P[i]] += dpP[j][k]; } int dpC[6][12*5+1] = {}; dpC[0][0] = 1; rep(i, 6) rep(j, c+1) rep(k, 12*j+1) { dpC[j+1][k+C[i]] += dpC[j][k]; } ll both[200] = {}; // サイコロP(p個),C(c個)を一度振ったときのパターン数 rep(i, 13*p+1) rep(j, 12*c+1) { (both[i+j] += dpP[p][i] * dpC[c][j] % MOD) %= MOD; } using namespace Matrix; int const M = 13*p + 12*c; Mat mat(M, Vec(M)); rep(i, M-1) mat[i][i+1] = 1; REP(i, 1, M+1) mat[M-1][M-i] = both[i]; mat = mat ^ (N+M-1); ll ans = 0; rep(i, M) (ans += mat[0][i]) %= MOD; cout << ans << endl; return 0; }