#include using namespace std; const int M = 1000000007; int main() { int t, a, b, c, d, e; cin >> t >> a >> b >> c >> d >> e; const int m = 20020, s = 10010; vector dp(m, 0); dp[s] = 1; for (int i = 0; i < t; ++i) { vector nex(m, 0); for (int j = 0; j < m; ++j) { if (dp[j] > 0) { nex[j + a] = (nex[j + a] + dp[j]) % M; nex[j - a] = (nex[j - a] + dp[j]) % M; nex[j + b] = (nex[j + b] + dp[j]) % M; nex[j - b] = (nex[j - b] + dp[j]) % M; nex[j + c] = (nex[j + c] + dp[j]) % M; nex[j - c] = (nex[j - c] + dp[j]) % M; } } dp = nex; } int ans = 0; for (int i = s + d; i <= s + e; ++i) ans = (ans + dp[i]) % M; cout << ans << "\n"; return 0; }