#include #include #include #include using namespace std; int T, a, b, c, d, e; int dp[500][20010]; long move(int now_time, int now_position){ if(now_time == T){ return d <= now_position && now_position <= e; }else if(dp[now_time][now_position + 10005] != -1){ return dp[now_time][now_position + 10005]; }else{ return dp[now_time][now_position + 10005] = (move(now_time + 1, now_position + a) + move(now_time + 1, now_position + b) + move(now_time + 1, now_position + c) + move(now_time + 1, now_position - a) + move(now_time + 1, now_position - b) + move(now_time + 1, now_position - c)) % long(1e9 + 7); } } int main(){ cin >> T >> a >> b >> c >> d >> e; for(int i = 0; i < 500; i++){ for(int j = 0; j < 20010; j++){ dp[i][j] = -1; } } cout << move(0, 0) << endl; }