#include <iostream>
using namespace std;

//const double PI = acos(-1);
using ll = long long;
using ull = unsigned long long;
const int inf = 2e9;
const ll INF = 2e18;
const ll MOD = 1e9+7;

#define REP(i,n) for (int i = 0; i < (n); i++)
#define sz(s) (s).size()
#define pb push_back
#define fi first
#define se second

ll n,a,b,c,d;
ll dp[1010][1010];
ll K[1010];
ll cc[1010][1010];
ll inv[1010];

ll mul(ll _a, ll _b) {
  if (_b == 0) return 1LL;
  if (_b == 1) return _a;
  ll ans = mul(_a, _b/2);
  ans *= ans;
  ans %= MOD;
  if (_b&1) ans *= _a;
  return ans % MOD;
}

ll C(ll _n, ll _k) {
  if (cc[_n][_k] != 0LL) return cc[_n][_k];
  if (_n == _k) return cc[_n][_k] = 1;
  return cc[_n][_k] = (K[_n] * ((inv[_k] * inv[_n-_k]) % MOD)) % MOD;
}

ll get(ll groups, ll mem, ll from) {
  ll ans = 1;

  REP(i,groups) {
    ans *= C(from, mem);
    ans %= MOD;
    from -= mem;
  }

  return (ans * inv[groups]) % MOD;
}

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);

  cin >> n >> a >> b >> c >> d;
  dp[0][0] = 1;

  K[1] = 1;
  inv[1] = 1;
  for (ll i = 2; i <= n; i++) {
    K[i] = K[i-1]*i;
    K[i] %= MOD;
    inv[i] = mul(K[i], MOD-2);
  }

  for (ll i = 1; i <= b; i++) {
    if (i < a) {
      dp[i][0] += dp[i-1][0];
      dp[i][0] %= MOD;
      continue;
    }
    REP(j,n+1) {
      dp[i][j] += dp[i-1][j];
      dp[i][j] %= MOD;
      ll k = c;
      while (k <= d && j + k * i <= n) {
        dp[i][j+k*i] += dp[i-1][j] * get(k, i, n-j);
        dp[i][j+k*i] %= MOD;
        k++;
      }
    }
  }
  cout << dp[b][n] << endl;
  return 0;
}

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define i_7 (ll)(1E9+7)
#define i_5 (ll)(1E9+5)
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    else return c+i_7;
}
typedef pair<int,int> i_i;
typedef pair<ll,ll> l_l;
ll inf=(ll)1E12;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll * pos,ll val){*pos=max(*pos,val);}//Max(&dp[i][j],dp[i-1][j]);
void Min(ll * pos,ll val){*pos=min(*pos,val);}
void Add(ll * pos,ll val){*pos=mod(*pos+val);}
const long double EPS=1E-8;
////////////////////////////////////////
#define N 100004

ll kai[N];
ll kai2[N];
ll po(ll i,ll p){
    if(p==0)return 1;
    else if(p==1)return mod(i);
    else if(p%2==0)return mod(po(mod(mod(i)*mod(i)),p/2));
    else  return mod(mod(i)*mod(po(i,p-1)));
}
void calc(){
    kai[0]=1;
    kai2[0]=1;
    for(int i=1;i<N;i++){
        kai[i]=mod(kai[i-1]*i);
        kai2[i]=mod(po(kai[i],i_5));
    }
}
ll comb(ll n,ll k){
    if(n==0){
        if(k==0)return 1;
        else return 0;
    }
    else if(n<k)return 0;
    else return mod(mod(mod(kai[n])*mod(kai2[n-k]))*mod(kai2[k]));
}

//#include <time.h>

int main(){
   // clock_t start = clock();    // スタート時間
    calc();
    ll n,a,b,c,d;cin>>n>>a>>b>>c>>d;
    ll dp[n+5][n+5];
    memset(dp,0,sizeof(dp));
    dp[a][0]=1;
    
    rep(k,a,b){
        rep(j,0,n){
            for(ll p=0;j+p*k<=n&&p<=d;p++){
                ll add=comb(n-j,p*k);
                add=mod(add*dp[k][j]);
                add=mod(add*kai[p*k]);
                add=mod(add*kai2[p]);
                ll w=(ll)po(kai2[k],p);
                add=mod(add*w);
                Add(&dp[k+1][j+p*k],add);
                if(p==0)p=c-1;
            }
        }
    }
    
    /*rep(i,0,b+1){
        rep(j,0,n){
            cout<<dp[i][j]<<"  ";
        }cout<<endl;
    }*/
    
    cout<<mod(dp[b+1][n])<<endl;
    
    //clock_t end = clock();     // 終了時間
   // std::cout << "duration = " << (double)(end - start) / CLOCKS_PER_SEC << "sec.\n";
    return 0;
}


