#include <algorithm>
#include <iostream>
#include <vector>
#include <math.h>
#include <set>
#include <map>
#include <string>
#include <stack>
#include <queue>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <bitset>
#include <complex>
#include <unistd.h>
#include <cassert>
#include <cctype>
#include <random>
#define _USE_MATH_DEFINES
#define _GLIBCXX_DEBUG
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> plglg;
typedef pair<double, ll> pdlg;
typedef tuple<int, int, int> tiii;
typedef tuple<ll, ll, ll> tlglglg;
typedef tuple<double, double, double> tddd;
typedef complex<double> xy_t;
#define REP(i, x, y) for(ll i = x; i < y; i++)
#define PER(i, x, y) for(ll i = x; i > y; i--)
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
double pi = 3.141592653589793;
ll mod = 1000000007;
int intmax = 2147483647;
int intmin = -2147483648;
ll llmax = 9223372036854775807;
ll llmin = -9223372036854775807;
int iinf = intmax / 8;
ll inf = llmax / 8;
double eps = 1e-11;

ll multiply(ll x, ll y) {
    return (x % mod) * (y % mod) % mod;
}

ll modpower(ll x, ll y) {
    if (y == 0) {
        return 1;
    } else if (y == 1) {
        return x % mod;
    } else if (y % 2 == 0) {
        ll p = modpower(x, y / 2);
        return p * p % mod;
    } else {
        ll p = modpower (x, y / 2);
        return (p * p) % mod * (x % mod) % mod;
    }
}

ll divide(ll x, ll y) {
    return multiply(x, modpower(y, mod - 2));
}

ll frac[1000000];
ll invfrac[1000000];

void fracinvfrac(ll n) {
    frac[0] = 1;
    for (int i = 1; i <= n; i++) {
        frac[i] = multiply(frac[i - 1], i);
    }
    invfrac[n] = divide(1, frac[n]);
    for (int i = n - 1; i >= 0; i--) {
        invfrac[i] = multiply(invfrac[i + 1], i + 1);
    }
}

ll modcombi(ll x, ll y) {
    if (x < y || y < 0) {
        return 0;
    } else if (y == 0) {
        return 1;
    } else {
        return multiply(multiply(frac[x], invfrac[x - y]), invfrac[y]);
    }
}

ll dp[1010][1010];

ll mcb[1010][1010];

int main() {
    ll N, A, B, C, D;
    cin >> N >> A >> B >> C >> D;
    fracinvfrac(10000);
    REP(i, 0, 1010) {
        fill(dp[i], dp[i] + 1010, 0);
        REP(j, 0, 1010) {
            mcb[i][j] = modcombi(i, j);
        }
    }
    dp[0][0] = 1;
    REP(i, 1, N + 1) {
        REP(j, 0, N + 1) {
            dp[i][j] = dp[i - 1][j];
        }
        if (A <= i && i <= B) {
            REP(j, 0, N + 1) {
                ll combi = 1;
                if (j + i * C <= N) {
                    REP(k, 1, C) {
                        combi = multiply(combi, mcb[N - j - i * (k - 1)][i]);
                    }
                    REP(k, C, D + 1) {
                        if (j + i * k <= N) {
                            combi = multiply(combi, mcb[N - j - i * (k - 1)][i]);
                            dp[i][j + i * k] = (dp[i][j + i * k]
                                                + multiply(dp[i - 1][j], multiply(combi, invfrac[k]))) % mod;  
                        }
                    }
                }
            }
        }
    }
    // REP(i, 0, N + 1) {
    //     REP(j, 0, N + 1) {
    //         cout << dp[i][j] << " ";
    //     }
    //     cout << endl;
    // }
    ll ans = dp[N][N];
    cout << ans << endl;
}

#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
//#include<bits/stdc++.h>
#include<cstdio>
#include<algorithm>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

const ll mod = 1e9 + 7;
ll modpow(ll A, ll B) {
	ll kotae = 1;
	while (B > 0) {
		if (B & 1) kotae = kotae * A % mod;
		A = A * A % mod;
		B >>= 1;
	}
	return kotae;
}
const int IMAX = 1001;
ll fac[IMAX + 1], ifac[IMAX + 1];
int dp[1001];

int main() {
	//cin.tie(0);
	//ios::sync_with_stdio(false);


	fac[0] = 1;
	rep1(i, IMAX) fac[i] = fac[i - 1] * i % mod;
	ifac[IMAX] = modpow(fac[IMAX], mod - 2);
	for (int i = IMAX; i > 0; i--) ifac[i - 1] = ifac[i] * i % mod;

	int N, A, B, C, D;
	scanf("%d %d %d %d %d", &N, &A, &B, &C, &D);
	dp[0] = fac[N];
	for (int i = A; i <= B; i++) {
		ll ic = modpow(ifac[i], C);
		for (int j = N - i * C; j >= 0; j--) {
			int tmp = dp[j] * ic % mod;
			int p = C;
			for (int k = j + i * C; k <= min(j + i * D, N); k += i) {
				dp[k] = (dp[k] + tmp * ifac[p++]) % mod;
				tmp = tmp * ifac[i] % mod;
			}
		}
	}
	printf("%lld", dp[N]);

	Would you please return 0;
}