#include #include const int MOD = 1000000007; const int SEG = 20000; int T, a, b, c, d, e; int dp[2][SEG + 10]; int main() { scanf("%d%d%d%d%d%d", &T, &a, &b, &c, &d, &e); dp[0][SEG / 2] = 1; for(int i=0; i SEG) continue; (dp[mo^1][npos] += dp[mo][j]) %= MOD; } } memset(dp[mo], 0, sizeof(dp[mo])); } int ans = 0; for(int i=d+SEG/2; i<=e+SEG/2; i++) { (ans += dp[T%2][i]) %= MOD; } printf("%d\n", ans); return 0; }