#include <bits/stdc++.h>
using namespace std;
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int long long
 
const int N=1e3+5;
const int MOD=1e9+7;
 
int n, a, b, c, d;
int cache[N][N], cache2[N][N];
int fact[N], invfact[N];
 
int pow(int a, int b, int m)
{
	int ans=1;
	while(b)
	{
		if(b&1)
			ans=(ans*a)%m;
		b/=2;
		a=(a*a)%m;
	}
	return ans;
}
 
int modinv(int k)
{
	return pow(k, MOD-2, MOD);
}
 
void precompute()
{
	fact[0]=fact[1]=1;
	for(int i=2;i<N;i++)
	{
		fact[i]=fact[i-1]*i;
		fact[i]%=MOD;
	}
	invfact[N-1]=modinv(fact[N-1]);
	for(int i=N-2;i>=0;i--)
	{
		invfact[i]=invfact[i+1]*(i+1);
		invfact[i]%=MOD;
	}
}
 
int nCr(int x, int y)
{
	if(y>x)
		return 0;
	int num=fact[x];
	num*=invfact[y];
	num%=MOD;
	num*=invfact[x-y];
	num%=MOD;
	return num;
}
 
int num(int r, int take)
{
	int &ans=cache2[r][take];
	if(ans!=-1)
		return ans;
	return modinv(pow(fact[r], take, MOD));
}
 
int dp2(int n, int r, int take)
{
	int ans=fact[n] * invfact[n-r*take];
	ans%=MOD;
	int den=num(r, take);
	ans*=den;
	ans%=MOD;
	return ans;
}
 
int dp(int remaining, int freq)
{
	if(remaining==0)
		return 1;
	if(freq==b+1)
		return 0;
	int &ans=cache[remaining][freq];
	if(ans!=-1)
		return ans;
	ans=dp(remaining, freq+1);
	for(int i=c;i<=d;i++)
	{
		int take=i*freq;
		if(take>remaining)
			break;
		int ways=dp2(remaining, freq, i);
		ways*=dp(remaining-take, freq+1);
		ways%=MOD;
		ways*=invfact[i];
		ways%=MOD;
		ans+=ways;
	}
	ans%=MOD;
	return ans;
}
 
int32_t main()
{
	IOS;
	precompute();
	memset(cache, -1, sizeof(cache));
	memset(cache2, -1, sizeof(cache2));
	cin>>n>>a>>b>>c>>d;
	int ans=dp(n, a);
	cout<<ans;
	cerr<<(double)clock()/CLOCKS_PER_SEC;
	return 0;
}
#include <bits/stdc++.h>
#define all(vec) vec.begin(),vec.end()
using namespace std;
using ll=long long;
using P=pair<int,int>;
const ll INF=1LL<<30;
const ll LINF=1LL<<61;
const double eps=1e-9;
const ll MOD=1000000007LL;
vector<ll> f,fi;
ll mpow(ll x,ll n){
    ll res=1;
    while(n>0){
        if(n&1){
            res=res*x%MOD;
        }
        x=x*x%MOD;
        n>>=1;
    }
    return res;
}
ll ncr(ll n,ll r){
    if(n<r)return 0;
    if(r==0)return 1;
    return f[n]*fi[r]%MOD*fi[n-r]%MOD;
}
int main(){
    int n;cin>>n;
    f.resize(n+10,0);
    fi.resize(n+10,0);
    f[0]=1;
    for(ll i=1;i<=n;i++)f[i]=f[i-1]*i%MOD;
    fi[n]=mpow(f[n],MOD-2LL);
    for(ll i=n-1;i>=0;i--)fi[i]=fi[i+1]*(i+1)%MOD;
    vector<vector<ll>> dp(n+10,vector<ll>(n+10,0));
    int a,b,c,d;cin>>a>>b>>c>>d;
    dp[a-1][0]=1;
    for(int i=a;i<=b;i++){
        for(int j=0;j<=n;j++){
            dp[i][j]+=dp[i-1][j];
            dp[i][j]%=MOD;
            ll s=1;
            for(int k=1;k<c;k++)s=s*ncr(n-j+i*k,i)%MOD;
            for(int k=c;k<=d;k++){
                if(j-i*k<0)break;
                s=s*ncr(n-j+i*k,i)%MOD;
                dp[i][j]+=dp[i-1][j-i*k]*s%MOD*fi[k]%MOD;
                dp[i][j]%=MOD;
            }
        }
    }
    cout<<dp[b][n]<<endl;
}
