#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include //#include //#include //#include //#include //#include //#include //#include //#include //#include //#if __cplusplus >= 201103L //#include //#include //#include //#include // //#define cauto const auto& //#else //#endif using namespace std; typedef long long ll; typedef pair pii; typedef pair pll; typedef vector vint; typedef vector > vvint; typedef vector vll, vLL; typedef vector > vvll, vvLL; #define VV(T) vector > template void initvv(vector > &v, int a, int b, const T &t = T()){ v.assign(a, vector(b, t)); } template void convert(const F &f, T &t){ stringstream ss; ss << f; ss >> t; } #define reep(i,a,b) for(int i=(a);i<(b);++i) #define rep(i,n) reep((i),0,(n)) #define ALL(v) (v).begin(),(v).end() #define PB push_back #define F first #define S second #define mkp make_pair #define RALL(v) (v).rbegin(),(v).rend() #define DEBUG #ifdef DEBUG #define dump(x) cout << #x << " = " << (x) << endl; #define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl; #else #define dump(x) #define debug(x) #endif #define MOD 1000000007LL #define EPS 1e-8 static const int INF=1<<24; int a[]={2,3,5,7,11,13}; int b[]={4,6,8,9,10,12}; vvll ret11; vvll ret12; vll ret2; void calc(vvll &aa,vvll &bb){ // vvll ret; initvv(ret11,150,150,0LL); rep(i,150) ret11[i][i]=1LL; rep(i,150){ rep(j,150){ ll tt=0LL; rep(k,150){ tt+=aa[i][k]*bb[k][j]; tt%=MOD; } ret11[i][j]=tt; } } ret11.swap(aa); } void foo(ll a,vvll &vv){ initvv(ret12,150,150,0LL); rep(i,150) ret12[i][i]=1LL; while(a){ if(a&1){ calc(ret12,vv); } a/=2; calc(vv,vv); } ret12.swap(vv); } void foo2(vvll &vv,vll &a){ rep(i,150) ret2[i]=0LL; rep(i,150){ rep(j,150){ ret2[i]+=vv[i][j]*a[149-i]; ret2[i]%=MOD; } } ret2.swap(a); } vint cc; vvint aaa; vvint bbb; void fa(int x){ if(x==0){ aaa.PB(cc); return; } rep(i,6){ cc.PB(a[i]); fa(x-1); cc.pop_back(); } } void fb(int x){ if(x==0){ bbb.PB(cc); return; } rep(i,6){ cc.PB(b[i]); fb(x-1); cc.pop_back(); } } void mainmain(){ ll n; cin>>n; ll aa,bb; cin>>aa>>bb; vvll vv; ret2=vll(150); vll v(150,0); // v[0]=1; bool f=false; if(n<150LL) f=true; ll ans=0; if(aa) fa(aa); if(bb) fb(bb); rep(i,aaa.size()){ sort(ALL(aaa[i])); } rep(i,bbb.size()){ sort(ALL(bbb[i])); } sort(ALL(aaa)); sort(ALL(bbb)); aaa.erase(unique(ALL(aaa)),aaa.end()); bbb.erase(unique(ALL(bbb)),bbb.end()); // dump(aaa.size()); vll ta(150,0LL); vll tb(150,0LL); rep(i,aaa.size()){ ll t=0LL; rep(j,aaa[i].size()){ t+=aaa[i][j]; t%=MOD; } ta[t]++; } rep(i,bbb.size()){ ll t=0LL; rep(j,bbb[i].size()){ t+=bbb[i][j]; t%=MOD; } tb[t]++; } // cout<=150) break; if(ta[i]==0||tb[j]==0) continue; v[i+j]+=ta[i]+tb[j]; v[i+j]%=MOD; } } initvv(vv,150,150,0LL); reep(i,1,150){ vv[i][i-1]=1LL; } rep(i,150){ vv[0][i]=v[i+1]; } vvll ttt=vv; if(!f) foo(n-149LL,vv); else{ reep(i,n,150){ ans+=v[i]; ans%=MOD; v[i]=0LL; } } foo2(vv,v); ans=0LL; ans+=v[149]; v[149]=0LL; while(1){ bool f=false; rep(i,150) if(v[i]) f=true; foo2(ttt,v); ans+=v[149]; ans%=MOD; v[149]=0LL; } cout<