#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include <iomanip>
#include <cassert>
#include <random>
#include <tuple>

#define rep(i,n) for (int i = 0; i < (n); ++i)

using namespace std;
typedef long long ll;
typedef pair<int, int> P;

const int MOD = 1e9 + 7;

const int MAX = 1100;
ll fac[MAX], finv[MAX], inv[MAX];

void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++) {
        fac[i] = fac[i-1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i-1] * inv[i] % MOD;
    }
}

ll COM(int n, int k) {
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n-k] % MOD) % MOD;
}

ll modpow(ll a, ll n, ll MOD) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % MOD;
        a = a * a % MOD;
        n >>= 1;
    }
    return res;
}


int main() {
    ll n, a, b, c, d;
    cin >> n >> a >> b >> c >> d;

    vector<ll> dp(n+1, 0);
    dp[0] = 1;

    COMinit();

    for (int i = a; i <= b; i++) {
        for (int j = n; j >= 0; j--) {
            for (int k = c; i*k <= j && k <= d; k++) {
                dp[j] += dp[j-i*k] * fac[n-(j-i*k)] % MOD * finv[n-j] % MOD * finv[k] % MOD * modpow(finv[i], k, MOD) % MOD;
                dp[j] %= MOD;
            }
        }
    }

    cout << dp[n] << endl;


    return 0;

}

#include <bits/stdc++.h>
using namespace std;

#define ll long long
const int N = 2005;
const int mod = 1e9+7;
int fac[N],combi[N][N];

int add(int x,int y) {
   int ret = ((x+y)%mod + mod)%mod;
   return ret;
}
int mul(int x,int y) {
   ll ret = (ll)x*y;
   ret%=mod;
   return ret;
}


int num[2];
int group[2];
int dp[N][N];
int inv[N];

int invFac[N];

int solveDp(int x,int rem) {
   if(rem==0) {
      return 1;
   }
   if(x>num[1]) {
      return 0;
   }
   int &ret = dp[x][rem];
   if(ret != -1) {
      return ret;
   }
   ret = solveDp(x+1,rem);
   int cur = 1;
   for(int j = 0;j<group[0];++j) {
      cur = mul(cur, invFac[x]);
   }
   for(int f = group[0];f<=group[1] && f*x<=rem;++f) {
      int tot = f*x;
      int m = fac[tot];
      int t = cur;
      t = mul(t, invFac[f]);
      m = mul(t,m);
      m = mul(combi[rem][tot],m);
      ret = add(ret, mul(m,solveDp(x+1,rem-tot)));
      cur = mul(cur,invFac[x]);
   }
   return ret;
}

int myPow(int x,int c) {
   int ret = 1;
   while(c>0) {
      if(c&1) {
         ret = mul(ret,x);
      }
      x = mul(x,x);
      c/=2;
   }
   return ret;
}
void solve() {
   int n;
   memset(dp,-1,sizeof(dp));
   scanf("%d",&n);
   for(int i=0;i<2;++i) {
      scanf("%d",&num[i]);
   }
   for(int i=0;i<2;++i) {
      scanf("%d",&group[i]);
   }
   fac[0] = 1;
   inv[0] = 1;
   invFac[0] = 1;
   for(int i=1;i<N;++i) {
      fac[i] = mul(fac[i-1],i);
      inv[i] = myPow(i,mod-2);
      invFac[i] = myPow(fac[i],mod-2);
   }
   for(int i=0;i<N;++i) {
      combi[i][i] = combi[i][0] = 1;
      for(int j = 1;j<i;++j) {
         combi[i][j] = add(combi[i-1][j],combi[i-1][j-1]);
      }
   }
   printf("%d\n", solveDp(num[0],n));
}

int main()
{
   //freopen("input.txt","r",stdin);
   solve();
}