#include<bits/stdc++.h>
using namespace std;
long long mod = 1e9 + 7;
long long fact[1005];
long long dp[1003][1003];
long long bigmod(long long a, long long p){
if(p == 0){
return 1;
}
long long ans = bigmod(a, p/2);
ans = (ans * ans) % mod;
if(p % 2 == 1){
ans = (ans * a) % mod;
}
return ans;
}
long long inverse(long long a){
return bigmod(a, mod - 2);
}
long long nCr(long long n, long long r){
return (fact[n] * inverse((fact[r] * fact[n - r]) % mod)) % mod;
}
long long group(long long a, long long k){
long long x = fact[a * k];
long long y = (bigmod(fact[a], k) * fact[k]) % mod;
return (x * inverse(y)) % mod;
}
int main(){
fact[0] = 1;
for(long long i = 1; i <= 1002; i++){
fact[i] = (fact[i - 1] * i) % mod;
}
int n, a, b, c, d;
cin >> n >> a >> b >> c >> d;
for(int i = 0; i <= b; i++){
for(int j = 0; j <= n; j++){
dp[i][j] = 0;
}
dp[i][0] = 1;
}
for(long long i = a; i <= b; i++){
for(long long j = 1; j <= n; j++){
dp[i][j] = dp[i - 1][j];
for(long long k = c; k <= d; k++){
if(j - k * i < 0){
break;
}
long long cur = (nCr(j, k * i) * dp[i - 1][j - k * i]) % mod;
cur = (cur * group(i, k)) % mod;
dp[i][j] = (dp[i][j] + cur) % mod;
}
}
}
cout << dp[b][n];
return 0;
}
I2luY2x1ZGU8Yml0cy9zdGRjKysuaD4KdXNpbmcgbmFtZXNwYWNlIHN0ZDsKbG9uZyBsb25nIG1vZCA9IDFlOSArIDc7CmxvbmcgbG9uZyBmYWN0WzEwMDVdOwpsb25nIGxvbmcgZHBbMTAwM11bMTAwM107CmxvbmcgbG9uZyBiaWdtb2QobG9uZyBsb25nIGEsIGxvbmcgbG9uZyBwKXsKICAgIGlmKHAgPT0gMCl7CiAgICAgICAgcmV0dXJuIDE7CiAgICB9CiAgICBsb25nIGxvbmcgYW5zID0gYmlnbW9kKGEsIHAvMik7CiAgICBhbnMgPSAoYW5zICogYW5zKSAlIG1vZDsKICAgIGlmKHAgJSAyID09IDEpewogICAgICAgIGFuc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gbG9uZyBrID0gYzsgayA8PSBkOyBrKyspewogICAgICAgICAgICAgICAgaWYoaiAtIGsgKiBpIDwgMCl7CiAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBsb25nIGxvbmcgY3VyID0gKG5DcihqLCBrICogaSkgKiBkcFtpIC0gMV1baiAtIGsgKiBpXSkgJSBtb2Q7CiAgICAgICAgICAgICAgICBjdXIgPSAoY3VyICogZ3JvdXAoaSwgaykpICUgbW9kOwogICAgICAgICAgICAgICAgZHBbaV1bal0gPSAoZHBbaV1bal0gKyBjdXIpICUgbW9kOwogICAgICAgICAgICB9CiAgICAgICAgfQogICAgfQogICAgY291dCA8PCBkcFtiXVtuXTsKICAgIHJldHVybiAwOwp9