#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; #define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i ) #define rep(i,n) REP(i,0,n) using ll = long long; const int inf=1e9+7; const ll longinf=1LL<<60 ; const ll mod=1e9+7 ; #define pai 3.141592653589793238462643383279 const int MAX = 11000000; const int MOD = 1000000007; long long fac[MAX], finv[MAX], inv[MAX]; // テーブルを作る前処理 void COMinit() { fac[0] = fac[1] = 1; finv[0] = finv[1] = 1; inv[1] = 1; for (int i = 2; i < MAX; i++){ fac[i] = fac[i - 1] * i % MOD; inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD; finv[i] = finv[i - 1] * inv[i] % MOD; } } // 二項係数計算 long long COM(int n, int k){ if (n < k) return 0; if (n < 0 || k < 0) return 0; return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD; } int main(){ ll n, m, d1, d2; cin >> n >> m >> d1 >> d2; ll zenbu = m-1-(n-1)*d1; if(zenbu<0){ cout << 0 << endl; return 0; } COMinit(); ll ans = 0; for(ll i=0; i<=n-1; i++){ if(i%2){ if(zenbu+(ll)n-(ll)(d2-d1+1)*i<0) break; ans-=COM(zenbu+(ll)n-(ll)(d2-d1+1)*i, n)*COM(n-1, i)%mod; if(ans<0) ans+=mod; ans%=mod; } else{ ans+=COM(zenbu+(ll)n-(ll)(d2-d1+1)*i, n)*COM(n-1, i); ans%=mod; } //cout << ans << endl; } cout << ans << endl; return 0; }