#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();
}
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdio>
const int N = 1e3 + 5;
const int mod = 1e9 + 7; 
using namespace std;

int n, a, b, c, d, fac[N], inv[N], g[N][N], f[N][N], ans; 

template < typename T >
inline T read()
{
	T x = 0, w = 1; char c = getchar();
	while(c < '0' || c > '9') { if(c == '-') w = -1; c = getchar(); }
	while(c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
	return x * w; 
}

int fpow(int x, int y)
{
	int res = 1;
	for( ; y; y >>= 1, x = 1ll * x * x % mod)
		if(y & 1) res = 1ll * res * x % mod;
	return res; 
}

int C(int n, int m)
{
	if(n < 0 || m < 0 || n < m) return 0;
	return 1ll * fac[n] * inv[m] % mod * inv[n - m] % mod; 
}

int main()
{
#ifndef ONLINE_JUDGE
	freopen("cpp.in", "r", stdin); 
#endif
	n = read <int> (), a = read <int> (), b = read <int> (), c = read <int> (), d = read <int> (); 
	for(int i = (fac[0] = 1); i <= n; i++) fac[i] = 1ll * fac[i - 1] * i % mod;
	inv[n] = fpow(fac[n], mod - 2);
	for(int i = n - 1; i >= 0; i--) inv[i] = 1ll * inv[i + 1] * (i + 1) % mod;
	g[0][0] = 1; 
	for(int res = 1, i = a; i <= b; i++, res = 1)
		for(int j = 1; j <= n && i * j <= n; j++)
			g[i * j][j] = 1ll * g[i * (j - 1)][j - 1] * C(i * j, i) % mod * inv[j] % mod * fac[j - 1] % mod; 
	f[a - 1][0] = 1; 
	for(int i = a; i <= b; i++)
		for(int j = 0; j <= n; j++)
		{
			f[i][j] = f[i - 1][j]; 
			for(int k = c; k <= d; k++)
			{
				if(i * k > j) break; 
				f[i][j] = (1ll * f[i - 1][j - i * k] * C(n - (j - i * k), i * k) % mod * g[i * k][k] + f[i][j]) % mod; 
			}
		}
	printf("%d\n", f[b][n]); 
	return 0; 
}
