#define _CRT_SECURE_NO_WARNINGS #define _USE_MATH_DEFINES #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; #include using namespace atcoder; #define REP(i,n) for(int i = 0; i < (int)n; i++) #define RREP(i,n) for(int i = (int)n-1; i >= 0; i--) #define LREP(i,n) for(LL i = 0; i < (LL)n; i++) #define Vi vector #define Vl vector #define LP pair #define P pair #define T3 tuple #define T4 tuple #define INF 1000000007 #define SIZE 1000010 #define MOD 1000000007 typedef long long LL; LL F[SIZE], FI[SIZE]; void init() { F[0] = FI[0] = 1; for (LL i = 1; i < SIZE; i++) { F[i] = (F[i - 1] * i) % MOD; FI[i] = (FI[i - 1] * inv_mod(i, MOD)) % MOD; } } LL comb(LL n, LL k) { if (n < k) return 0; LL res = F[n]; res = (res * FI[n - k]) % MOD; res = (res * FI[k]) % MOD; return res; } LL N, M, D1, D2; LL cal(LL x) { LL n = (M - 1) - (N - 1) * D1; n -= x * (D2 - D1 + 1); LL res = comb(n + N, N); res = (res * comb(N - 1, x)) % MOD; return res; } int main() { cin >> N >> M >> D1 >> D2; init(); LL ans = 0; for (LL x = 1; x <= N - 1; x++) { LL res = cal(x); if (x % 2 == 1) { ans = (ans + res) % MOD; } else { ans = (ans - res) % MOD; } } ans = (cal(0) - ans) % MOD; cout << (ans + MOD) % MOD << endl; }