#include #include #include using namespace std; typedef long long int ll; const int MAX_T = 500; const int MOD = 1000000007; int T, a, b, c, d, e; int comb[MAX_T + 10][MAX_T + 10]; int main() { for(int i=0; i<=MAX_T; i++) comb[i][0] = 1; for(int i=1; i<=MAX_T; i++) { for(int j=1; j<=i; j++) comb[i][j] = (comb[i-1][j-1] + comb[i-1][j]) % MOD; } scanf("%d%d%d%d%d%d", &T, &a, &b, &c, &d, &e); int ans = 0; for(int x=-T; x<=T; x++) { int P = T - abs(x); for(int y=-P; y<=P; y++) { int Q = P - abs(y); for(int z=-Q; z<=Q; z++) { int rest = Q - abs(z); if(rest % 2) continue; rest = rest / 2 * 2; int val = a*x + b*y + c*z; if(val < d || e < val) continue; for(int i=0; i<=rest; i+=2) { for(int j=0; j<=rest-i; j+=2) { int k = rest - i - j; int X = abs(x), Y = abs(y), Z = abs(z); int N = T; int array[] = {X+i/2, i/2, Y+j/2, j/2, Z+k/2, k/2}; long long int temp = 1; for(int s=0; s<6; s++) { (temp *= comb[N][array[s]]) %= MOD; N -= array[s]; } (ans += temp) %= MOD; } } } } } printf("%d\n", ans); return 0; }