import std.stdio;
import std.conv, std.array, std.algorithm, std.string;
import std.math, std.random, std.range, std.datetime;
import std.bigint;

void main(){
	int n, a, b, c, d;
	{
		int[] tmp = readln.chomp.split.map!(to!int).array;
		n = tmp[0], a = tmp[1], b = tmp[2], c = tmp[3], d = tmp[4];
		}
	
	ulong[] xsz = [1];
	for(int i = 1; i <= n; i ++) xsz ~= 0;
	for(int k = a; k <= b; k ++){
		debug writeln("k=", k, " (upto ", k, " person per group)");
		ulong[] xs;
		for(int i = 0; i <= n; i ++) xs ~= 1;
		
		ulong[] qs = [1, 1];
		for(int j = 2; j <= d; j ++){
			qs ~= quot(prod(qs[j - 1], binom2(prod(j, k), k)), j);
			}
		debug writeln("qs=", qs, " (# of ways to divide jk persons into j groups of k persons each)");
		for(int i = 0; i <= n; i ++){
			debug writeln(" i=", i, " (# of ways to divide ", i, " persons into groups)");
			xs[i] = xsz[i];
			debug writeln("   x=", xs[i]);
			for(int j = c; j <= d; j ++){
				debug writeln("  j=", j, " (if you use ", j, " groups of ", k, " persons)");
				if(i - j * k >= 0){
					xs[i] += prod(xsz[i - j * k], binom2(i, j * k), qs[j]);
					xs[i] %= mod;
					debug writeln("   x=", xs[i]);
					}
				}
			}
		
		xsz = xs;
		}
	
	xsz[n].writeln;
	
	}

ulong[] fracs = [1];

ulong binom2(ulong n, ulong k){
	if(k == 0 || n - k == 0) return 1;
	if(fracs.length < 10) for(int i = 1; i <= 1000; i ++){
		fracs ~= fracs[i - 1] * i % mod;
		}
	return fracs[cast(int) n] * inv(fracs[cast(int) k]) % mod * inv(fracs[cast(int) (n - k)]) % mod;
	}



// -------

const ulong mod = 1_000_000_007;
	// assert(mod % 2 > 0);
	// for(int i = 3; i * i <= x; i += 2) assert(x % i > 0);
	// assert(mod * mod < ulong.max);
	
const int nmax = 1_000_000;
		
ulong sum(ulong[] xs ...){
	ulong ans = 0;
	foreach(x; xs){
		ans += x;
		ans %= mod;
		}
	return ans;
	}

ulong diff(ulong x, ulong y){
	return (x - y) % mod;
	}

ulong prod(ulong[] xs ...){
	ulong ans = 1;
	foreach(x; xs){
		ans *= x;
		ans %= mod;
		}
	return ans;
	}

ulong quot(ulong x, ulong y){
	assert(y > 0);
	return x * inv(y) % mod;
	}

ulong inv(ulong x){
	assert(x > 0 && x < nmax);
	static bool inited = false;
	static ulong[nmax] _inv;
	if(!inited){
		_inv[1] = 1;
		foreach(i; 2 .. nmax){
			_inv[i] = (mod - mod / i) * _inv[mod % i] % mod;
			}
		inited = true;
		}
	return _inv[cast(int) x];
	}

ulong frac(ulong x){
	assert(x < nmax);
	static bool inited = false;
	static ulong[nmax] _frac;
	if(!inited){
		_frac[0] = 1;
		foreach(i; 1 .. nmax){
			_frac[i] = _frac[0] * i % mod;
			}
		inited = true;
		}
	return _frac[cast(int) x];
	}

ulong invfrac(ulong x){
	assert(x < nmax);
	static bool inited = false;
	static ulong[nmax] _invfrac;
	if(!inited){
		_invfrac[0] = 1;
		foreach(i; 1 .. nmax){
			_invfrac[i] = _invfrac[0] * inv(i) % mod;
			}
		inited = true;
		}
	return _invfrac[cast(int) x];
	}

ulong binom(ulong n, ulong k){
	assert(n < nmax);
	assert(k <= n);
	if(k == 0 || n - k == 0) return 1;
	else return frac(n) * invfrac(k) % mod * invfrac(n - k) % mod;
	}

