import std.stdio, std.string, std.conv;
import std.range, std.algorithm, std.array, std.typecons, std.container;
import std.math, std.numeric, core.bitop;

enum mod = 10L^^9 + 7;

void main() {
    int n, a, b, c, d;
    scan(n, a, b, c, d);

    auto fact = new long[](n + 1);
    auto rfact = new long[](n + 1);
    fact[0] = 1;
    foreach (i ; 1 .. n + 1) {
        fact[i] = (fact[i-1] * i) % mod;
    }
    rfact[n] = inv(fact[n]);
    foreach_reverse (i ; 0 .. n) {
        rfact[i] = (rfact[i+1] * (i + 1)) % mod;
    }

    long perm(int n, int k) {
        return fact[n] * rfact[n-k] % mod;
    }

    debug {
        //writeln(fact);
        //writeln(rfact);
    }

    auto dp = new long[][](n + 1, n + 1);
    foreach (i ; 0 .. n/a + 1) {
        if (i != 0 && (i < c || i > d)) {
            continue;
        }
        dp[a][i*a] = perm(n, i*a) * powmod(rfact[a], i) % mod * rfact[i] % mod;
    }

    foreach (i ; a + 1 .. b + 1) {
        foreach (j ; 0 .. n + 1) {
            foreach (k ; 0 .. min(d, j/i) + 1) {
                if (k != 0 && (k < c || k > d)) {
                    continue;
                }
                (dp[i][j] += dp[i-1][j - i*k] * perm(n - j + i*k, i*k)
                    % mod * powmod(rfact[i], k) % mod * rfact[k] % mod)
                %= mod;
            }
        }
    }

    debug {
        writefln("%(%(%s %)\n%)", dp);
    }

    long ans = dp[b][n];

    writeln(ans);
}

long powmod(long x, long y) {
    return y > 0 ? powmod(x, y>>1)^^2 % mod * x^^(y&1) % mod : 1;
}

long inv(long x) {
    return powmod(x, mod - 2);
}


void scan(T...)(ref T args) {
    import std.stdio : readln;
    import std.algorithm : splitter;
    import std.conv : to;
    import std.range.primitives;

    auto line = readln().splitter();
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}



void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}
