#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #define fi first #define se second #define rep(i,n) for(int i = 0; i < n; ++i) #define rrep(i,n) for(int i = 1; i <= n; ++i) #define drep(i,n) for(int i = n-1; i >= 0; --i) #define gep(i,g,j) for(int i = g.head[j]; i != -1; i = g.e[i].next) #define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++) #define rng(a) a.begin(),a.end() #define maxs(x,y) x = max(x,y) #define mins(x,y) x = min(x,y) #define pb push_back #define sz(x) (int)(x).size() #define pcnt __builtin_popcount #define snuke srand((unsigned)clock()+(unsigned)time(NULL)); using namespace std; typedef long long int ll; typedef pair P; typedef vector vi; typedef vector vvi; inline int in() { int x; scanf("%d",&x); return x;} inline void priv(vi a) { rep(i,sz(a)) printf("%d%c",a[i],i==sz(a)-1?'\n':' ');} const int MX = 155, MN = 12, INF = 1000010000; const ll LINF = 1000000000000000000ll; const double eps = 1e-10; const int a[2][6] = {{2,3,5,7,11,13},{4,6,8,9,10,12}}; ll n, p, c; // Mod int const int mod = 1000000007; struct mint{ ll x; mint():x(0){} mint(ll x):x((x%mod+mod)%mod){} mint operator+=(const mint& a){ if((x+=a.x)>=mod) x-=mod; return *this;} mint operator-=(const mint& a){ if((x+=mod-a.x)>=mod) x-=mod; return *this;} mint operator*=(const mint& a){ (x*=a.x)%=mod; return *this;} mint operator+(const mint& a)const{ return mint(*this) += a;} mint operator-(const mint& a)const{ return mint(*this) -= a;} mint operator*(const mint& a)const{ return mint(*this) *= a;} bool operator==(const mint& a)const{ return x == a.x;} }; // // Matrix struct mat{ typedef mint TT; int h, w; vector > d; mat(){} mat(int h, int w, TT v=0):h(h),w(w),d(h,vector(w,v)){} void fil(TT v=0){ rep(i,h)rep(j,w) d[i][j] = v;} void uni(){ rep(i,h)rep(j,w) d[i][j] = (i==j);} mat operator*(const mat& a)const{ // w = a.h mat res(h,a.w); rep(i,h)rep(k,w)rep(j,a.w) res.d[i][j] += d[i][k]*a.d[k][j]; return res; } mat power(ll a){ // h = w if(a == 0){ mat res(h,w); res.uni(); return res; } mat res = power(a/2); res = res*res; if(a&1) res = res*(*this); return res; } }; // mint dp[MX]; mint d[MN][MX]; int main(){ vi p(2); cin >> n >> p[0] >> p[1]; d[0][0] = 1; rep(i,6) { rep(j,p[0])for (int k = a[0][i]; k < MX-2; ++k) { d[j+1][k] += d[j][k-a[0][i]]; } } rep(i,MX) d[0][i] = d[p[0]][i]; rrep(i,MN-1)rep(j,MX) d[i][j] = 0; rep(i,6) { rep(j,p[1])for (int k = a[1][i]; k < MX-2; ++k) { d[j+1][k] += d[j][k-a[1][i]]; } } rep(i,MX) dp[i] = d[p[1]][i]; int s = MX-5; mat x(s,s), y(s,1); rep(i,s-1) x.d[i+1][i] = 1; rep(i,s) x.d[0][i] = dp[i+1]; y.d[0][0] = 1; x = x.power(n-1); y = x*y; mint ans = 0, sum = 0; rep(i,s) { sum += dp[s-i]; ans += y.d[s-i-1][0]*sum; // cout<