#include "bits/stdc++.h" #include #include #include #include #include #include #include #include #include #include #include #include #include #pragma warning(disable:4996) using namespace std; using ld = long double; template using Table = vector>; const ld eps=1e-9; #define WHATS(var)cout<<__LINE__<<' '<<#var<<"="< ostream& operator <<(ostream &os, const pair v){ os << "( " << v.first << ", " << v.second << ")"; return os; } template ostream& operator <<(ostream &os, const vector &v){ for(int i = 0; i < v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os; } template ostream& operator <<(ostream &os, const vector> &v){ for(int i = 0; i < v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os; } template ostream& operator <<(ostream &os, const vector> &v){ for(int i = 0; i < v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os; } template ostream& operator <<(ostream &os, const set &v){ int i=0; for(auto it:v){ if(i > 0){os << ' ';} os << it; i++; } return os; } /* 1 2 3 4 5 6 7 8 9 10 11 12 13 14 12 1 11 13 3 10 14 5 9 15 7 8 16 2 14 17 4 13 18 6 12 1-12 11 1 10 12 3 9 13 5 8 13 6 7 14 2 12 15 4 11 */ const int MAX_X=2220; using ll=long long ; const int mod = 1000000007; struct Mod { public: int num; Mod() : Mod(0) { ; } Mod(long long int n) : num((n % mod + mod) % mod) { static_assert(mod(n)) { ; } operator int() { return num; } }; Mod operator+(const Mod a, const Mod b) { return Mod((a.num + b.num) % mod); } Mod operator+(const long long int a, const Mod b) { return Mod(a) + b; } Mod operator+(const Mod a, const long long int b) { return b + a; } Mod operator++(Mod &a) { return a + Mod(1); } Mod operator-(const Mod a, const Mod b) { return Mod((mod + a.num - b.num) % mod); } Mod operator-(const long long int a, const Mod b) { return Mod(a) - b; } Mod operator--(Mod &a) { return a - Mod(1); } Mod operator*(const Mod a, const Mod b) { return Mod(((long long)a.num * b.num) % mod); } Mod operator*(const long long int a, const Mod b) { return Mod(a)*b; } Mod operator*(const Mod a, const long long int b) { return Mod(b)*a; } Mod operator*(const Mod a, const int b) { return Mod(b)*a; } Mod operator+=(Mod &a, const Mod b) { return a = a + b; } Mod operator+=(long long int &a, const Mod b) { return a = a + b; } Mod operator-=(Mod &a, const Mod b) { return a = a - b; } Mod operator-=(long long int &a, const Mod b) { return a = a - b; } Mod operator*=(Mod &a, const Mod b) { return a = a * b; } Mod operator*=(long long int &a, const Mod b) { return a = a * b; } Mod operator*=(Mod& a, const long long int &b) { return a = a * b; } Mod operator^(const Mod a, const int n) { if (n == 0) return Mod(1); Mod res = (a * a) ^ (n / 2); if (n % 2) res = res * a; return res; } Mod mod_pow(const Mod a, const int n) { if (n == 0) return Mod(1); Mod res = mod_pow((a * a), (n / 2)); if (n % 2) res = res * a; return res; } Mod inv(const Mod a) { return a ^ (mod - 2); } Mod operator/(const Mod a, const Mod b) { assert(b.num != 0); return a * inv(b); } Mod operator/(const long long int a, const Mod b) { return Mod(a) / b; } Mod operator/=(Mod &a, const Mod b) { return a = a / b; } #define MAX_MOD_N 2024000 Mod fact[MAX_MOD_N], factinv[MAX_MOD_N]; void init(const int amax = MAX_MOD_N) { fact[0] = Mod(1); factinv[0] = 1; for (int i = 0; i < amax - 1; ++i) { fact[i + 1] = fact[i] * Mod(i + 1); factinv[i + 1] = factinv[i] / Mod(i + 1); } } Mod comb(const int a, const int b) { return fact[a] * factinv[b] * factinv[a - b]; } int main() { init(); ios::sync_with_stdio(false); ll N,M,D1,D2;cin>>N>>M>>D1>>D2; M-=1+D1*(N-1); Mod answer=0; if(M<0){ }else{ ll K=D2-D1; for(int over=0;over<=N-1;++over){ Mod val=over%2?Mod(-1):Mod(1); ll rest=M-(K+1)*over; if(rest<0)break; else{ Mod cnt=comb(N-1,over)*comb(N+rest,N); answer+=val*cnt; } } } cout<