// Slower C++ solution:
#include<set>

#include<map>

#include<stack>

#include<queue>

#include<deque>

#include<cmath>

#include<cstdio>

#include<cctype>

#include<string>

#include<vector>

#include<cstdlib>

#include<cstring>

#include<sstream>

#include<iostream>

#include<algorithm>

#define MAXN 1000

#define hlq 1000000007



using namespace std;

int c,d,C[MAXN+8][MAXN+8],dp[MAXN+8][MAXN+8],fac[MAXN+8];

int DP(int l,int r,int res)

{

	if(res==0)

		return 1;

	if(r<l)

		return 0;

	if(~dp[r][res])

		return dp[r][res];

	dp[r][res]=DP(l,r-1,res);

	int i,k=min(d,res/r),f=1,t=res,tmp=0;

	if(c>k)

		return dp[r][res];

	for(i=1;i<c&&t>=r;i++)

	{

		f=(1LL*f*C[t][r])%hlq;

		t-=r;

	}

	for(i=c;i<=k&&t>=r;i++)

	{

		f=(1LL*f*C[t][r])%hlq;

		t-=r;

		tmp=1LL*DP(l,r-1,t)*f%hlq;

		tmp=1LL*tmp*fac[i]%hlq;

		dp[r][res]=(tmp+dp[r][res])%hlq;

	}

	return dp[r][res];

}

int pow_mod(long long a,int x)

{

	long long ans=1;

	while(x)

	{

		if(x&1)

			ans=ans*a%hlq;

		a=a*a%hlq;

		x>>=1;

	}

	return (int)ans;

}

int main()

{

	int n,a,b,i,j;

	scanf("%d%d%d%d%d",&n,&a,&b,&c,&d);

	memset(dp,-1,sizeof(dp));

	for(i=0;i<=n;i++)

	{

		C[i][0]=1;

		for(j=1;j<=i;j++)

			C[i][j]=(C[i-1][j]+C[i-1][j-1])%hlq;

	}

	fac[0]=1;

	for(i=1;i<=n;i++)

		fac[i]=1LL*fac[i-1]*pow_mod(i,hlq-2)%hlq;

	printf("%d",DP(a,b,n));

	return 0;

}

// Faster C++ solution for the same problem (measured speedup: 5.051780436678218x):
#include <bits/stdc++.h>

#define fto(i,a,b) for(int i=a; i<=b;++i)

#define fdto(i,a,b) for(int i=a; i>=b;--i)

#define fi first

#define se second

#define mp make_pair

#define pb push_back

#define pii pair<ll,ll>

#define ll long long

#define maxn 300009

#define maxm 100009

#define gb(i,j) ((i>>j)&1)

#define name "a"

#define endl '\n'

#define int ll



using namespace std;



const int mod=1e9+7;



int mu(int a, int b){

    if(b==0)return 1;

    int tg=mu(a,b/2);

    tg=(tg*tg)%mod;

    if(b%2)tg=(tg*a)%mod;

    return tg;

}

int p[2009],p1[2009];

int C(int a, int b){

    return p[a+b]*p1[a]%mod *p1[b] %mod;

}

int n,a,b,c,d,h[2009][2009],f[2009][2009],h1[2009][2009];

main()

{

    ios_base::sync_with_stdio(0);

    cin.tie(0);

    cout.tie(0);

    cin >> n >> a >> b >> c >> d;

    p[0]=1;

    fto(i,1,n*2)p[i]=p[i-1]*i%mod;

    fto(i,0,n*2)p1[i]=mu(p[i],mod-2);

    fto(i,0,n)

        fto(j,0,n)h[i][j]=C(i,j);

    fto(i,1,n){

        h1[i][1]=1;

        fto(j,2,d){

            if(j*i>n)break;

            h1[i][j]=(h1[i][j-1]*h[i][j*i-i])%mod;

        }

        fto(j,2,d){

            if(j*i>n)break;

            h1[i][j]=(h1[i][j]*p1[j])%mod;

        }

    }

    f[0][a-1]=1;

    for(int i=a; i<=b; ++i){

        for(int j=i*c; j<=i*d && j<=n;j+=i)

            for(int t=j; t<=n; ++t)

            if(f[t-j][i-1]){

                f[t][i]=(f[t][i]+f[t-j][i-1]*h[j][n-t]%mod * h1[i][j/i])%mod;

                //if(f[t][i]) cout << f[t-j][i-1]<<' '<< t <<' '<< j <<' '<< h[j][n-t]<<' '<< h1[i][j/i]<<endl;

            }

        //cout << i <<endl;

        //fto(j,0,n)cout << j <<' '<<f[j][i]<<endl;

        fto(j,0,n)f[j][i]=(f[j][i]+f[j][i-1])%mod;

    }

    cout << f[n][b];

    return 0;

}