#include<bits/stdc++.h> //Ithea Myse Valgulious
namespace chtholly{
typedef long long ll;
#define re0 register int
#define rel register ll
#define rec register char
#define gc getchar
//#define gc() (p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<23,stdin),p1==p2)?-1:*p1++)
#define pc putchar
#define p32 pc(' ')
#define pl puts("")
/*By Citrus*/
char buf[1<<23],*p1=buf,*p2=buf;
inline int read(){
  int x=0,f=1;char c=gc();
  for (;!isdigit(c);c=gc()) f^=c=='-';
  for (;isdigit(c);c=gc()) x=(x<<3)+(x<<1)+(c^'0');
  return f?x:-x;
  }
template <typename mitsuha>
inline bool read(mitsuha &x){
  x=0;int f=1;char c=gc();
  for (;!isdigit(c)&&~c;c=gc()) f^=c=='-';
  if (!~c) return 0;
  for (;isdigit(c);c=gc()) x=(x<<3)+(x<<1)+(c^'0');
  return x=f?x:-x,1;
  }
template <typename mitsuha>
inline int write(mitsuha x){
  if (!x) return 0&pc(48);
  if (x<0) pc('-'),x=-x;
  int bit[20],i,p=0;
  for (;x;x/=10) bit[++p]=x%10;
  for (i=p;i;--i) pc(bit[i]+48);
  return 0;
  }
inline char fuhao(){
  char c=gc();
  for (;isspace(c);c=gc());
  return c;
  }
}using namespace chtholly;
using namespace std;
const int aoi=2038,mod=1e9+7;
ll dp[aoi],inv[aoi];

ll kasumi(ll a,ll b=mod-2) {
ll s=1;
for (;b;b>>=1,a=a*a%mod) if (b&1) s=s*a%mod;
return s;
}

int main() {
int n,a,b,c,d,i,j,k;
read(n),read(a),read(b),read(c),read(d);
for (dp[n]=i=1;i<=n;++i) dp[n]=dp[n]*i%mod;
inv[n]=kasumi(dp[n]);
for (i=n;i;--i) inv[i-1]=inv[i]*i%mod;
for (i=a;i<=b;++i)
  for (j=0;j<=n;++j) 
    for (k=c;k<=d&&j+i*k<=n;++k) 
      dp[j]=(dp[j]+dp[j+i*k]*kasumi(inv[i],k)%mod*inv[k]%mod)%mod;
cout<<*dp<<"\n";
}
#include <bits/stdc++.h>
 
using namespace std;
inline void prep ()
{
  cin.tie (0);
  cin.sync_with_stdio (0);
};
const double pi = acos(-1.);
//printf(%.12lf\n,mid);
// __builtin_popcount(int) count 1's in binary
// get decimal part of number
/*
double intpart;
double thiss = modf((double)(n*m)/(double)k, &intpart);
*/
// round = (int)(num+.5)
long long mod = 1000000007;

// 32 mil = ~1 sec 
long long mymod(long long num){
  if (num< 0 && !(num%mod == 0)){
    if (mod == 1){
      return 0;
    }
    return mod-abs(num)%mod;
  }else{
    return num%mod;
  }
}
 
/*string sentence = And I feel fine...;
    istringstream iss(sentence);
*/  
 
double eps = .000000001;


long long modpow(long long x, long long n) { 
  if (n == 0) return 1%mod; 
  long long u = modpow(x,n/2); 
  u = (u*u)%mod; 
  if (n%2 == 1) u = (u*x)%mod; 
  return u;
}
long long n, a, b, c, d;
bool memoo[1001][1001];
long long memo[1001][1001];
long long shortmod(long long num){
    if (num >= mod){
        num -= mod;
    }
    return num;
}
void EE(int a, int b, int& x, int& y)
{
    if(a%b == 0)
    {
        x=0;
        y=1;
        return;
    }
    EE(b,a%b,x,y);
    int temp = x;
    x = y;
    y = temp - y*(a/b);
}
int inverse(int a)
{
    int x,y;
    EE(a,mod,x,y);
    if(x<0) x += mod;
    return x;

}
long long facts[1001];
long long invfacts[1001];
long long inverses[1001];
long long func(int left, int grpsze){
  
    if (left == 0 && grpsze > b){
        return 1;
    }
    if (left < 0 || grpsze > b){
        return 0;
    }
    
    if (memoo[left][grpsze]){
        return memo[left][grpsze];
    }
    long long res = 0;
    
    long long choose = 1;
    int templeft = left;
 
    templeft -= grpsze*(c-1);
    choose *= modpow(invfacts[grpsze], c-1);
    choose %= mod;
    choose *= invfacts[c-1];
    choose %= mod;
    for (int i=c; i <= d; i++){
        if (templeft <= 0){
            break;
        }
        choose *= invfacts[grpsze];
        choose %= mod;
        choose *= inverses[i];
        choose %= mod;
        templeft -= grpsze;
        res += (choose*func(templeft, grpsze+1))%mod;
        res = shortmod(res);
        
    }
    res += func(left, grpsze+1);
    res = shortmod(res);
    memoo[left][grpsze] = true;
    memo[left][grpsze] = res;
    return res;
}
int main ()
{
  prep();
  
  cin >> n >> a >> b >> c >> d;
 
  long long cur = 1;
  for (int i=1; i<=1000; i++){
      cur *= i;
      cur %= mod;
      facts[i] = cur;
  }
  facts[0] = 1;
  invfacts[0] = 1;
  inverses[0] = 1;
  cur = 1;
  for (int i=1; i<=1000; i++){
      cur *= inverse(i);
      cur %= mod;
      invfacts[i] = cur;
  }
  for (int i=1; i<=1000; i++){
      inverses[i] = inverse(i);
  }
  cout << (facts[n]*func(n, a))%mod;
  
  return 0; 
}
