#include using namespace std; using i64 = long long; #define rep(i,s,e) for(int (i) = (s);(i) <= (e);(i)++) i64 T; i64 a,b,c,d,e; vector dp[2]; i64 MOD = 1e9 + 7; int main(){ dp[0].resize(20202,0); dp[1].resize(20202,0); cin >> T >> a >> b >> c >> d >> e; dp[0][10101] = 1; d += 10101; e += 10101; vector dd = {a,b,c,-a,-b,-c}; for(int c = 1;c <= T;c++){ auto& before = dp[0]; auto& next = dp[1]; next.assign(20202,0); for(int i = 0;i < 20002;i++){ for(auto j : dd){ if(i - j >= 0) next[i] = (next[i] + before[i - j]) % MOD; } } swap(next,before); } i64 ans = 0; for(int i = d;i <= e;i++){ ans = (ans + dp[0][i]) % MOD; } cout << ans << endl; }