#include using namespace std; using VS = vector; using LL = long long; using VI = vector; using VVI = vector; using PII = pair; using PLL = pair; using VL = vector; using VVL = vector; #define ALL(a) begin((a)),end((a)) #define RALL(a) (a).rbegin(), (a).rend() #define SZ(a) int((a).size()) #define SORT(c) sort(ALL((c))) #define RSORT(c) sort(RALL((c))) #define UNIQ(c) (c).erase(unique(ALL((c))), end((c))) #define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++) #define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)--) #define debug(x) cerr << #x << ": " << x << endl const int INF = 1e9; const LL LINF = 1e16; const LL MOD = 1000000007; const double PI = acos(-1.0); int DX[8] = { 0, 0, 1, -1, 1, 1, -1, -1 }; int DY[8] = { 1, -1, 0, 0, 1, -1, 1, -1 }; /* ----- 2018/08/21 Problem: yukicoder 212 / Link: http://yukicoder.me/problems/no/212 ----- */ /* ------問題------ -----問題ここまで----- */ /* -----解説等----- ----解説ここまで---- */ template vector> mul(vector> &A, vector> &B) { vector> C(A.size(), vector(B[0].size())); FOR(i, 0, (int)A.size()) { FOR(k, 0, (int)B.size()) { if (A[i][k]) { FOR(j, 0, (int)B[0].size()) { C[i][j] = (C[i][j] + (A[i][k]) * (B[k][j])) % MOD; } } } } return C; } template vector> pow(vector> A, long long n) { vector> B((int)A.size(), vector((int)A.size())); FOR(i, 0, (int)A.size()) { B[i][i] = 1; } while (n > 0) { if (n & 1) B = mul(B, A); A = mul(A, A); n >>= 1; } return B; } int main() { cin.tie(0); ios_base::sync_with_stdio(false); VI pdice = { 2,3,5,7,11,13 }; VI cdice = { 4,6,8,9,10,12 }; LL N, P, C; cin >> N >> P >> C; auto makeDP = [](int n, const VI&dice) { VVI dp(n + 1, VI(dice.back() * n + 1, 0)); dp[0][0] = 1; for (int d : dice) { FOR(i, 0, n) { FOR(x, 0, 13 * n + 1 - d) { (dp[i + 1][x + d] += dp[i][x]) %= MOD; } } } return dp.back(); }; VI Pdp = makeDP(P, pdice); VI Cdp = makeDP(C, cdice); //FOR(i, 0, pdice.back()*P + 1) { // cout << "Pdp[" << i << "]:=" << Pdp[i] << " ,"; //}cout << endl; //debug(accumulate(ALL(Pdp), 0)); int sz = P * pdice.back() + C * cdice.back(); VL cmtable(sz + 1, 0); FOR(i, 0, P*pdice.back()+1) { FOR(j, 0, C*cdice.back()+1) { (cmtable[i + j] += Pdp[i] * Cdp[j]) %= MOD; } } VVL T(sz, VL(sz, 0)); FOR(i, 0, sz - 1)T[i + 1][i] = 1; FOR(i, 0, sz)T[0][i] = cmtable[i + 1]; T = pow(T, N); LL ans = 0; FOR(i, 0, sz) { (ans += T[0][i])%=MOD; } cout << ans << "\n"; return 0; }