#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(202020,0); dp[1].resize(202020,0); cin >> T >> a >> b >> c >> d >> e; dp[0][101010] = 1; d += 101010; e += 101010; 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(202020,0); for(int i = 0;i < 200020;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; }