#include using namespace std; #define DEBUG_MODE #define endl '\n' #ifdef DEBUG_MODE #define DEBUG(X) debug_func(X, #X) #define DEBUG_ENDL endl << flush #define DEBUG_SEPARATOR_LINE cout<<"=================\n" #else #define DEBUG(X) 0 #define DEBUG_ENDL 0 #define DEBUG_SEPARATOR_LINE 0 #endif #define ALL(V) (V).begin(), (V).end() #define ALLR(V) (V).rbegin(), (V).rend() #define DEBUG_ENDL_S(S) ((S).size() ? "\n" : "") << flush; template using V = vector; template using VV = V>; template using P = pair; using ll = int64_t; using PLL = P; template const T& var_min(const T &t) { return t; } template const T& var_max(const T &t) { return t; } template const Head& var_min(const Head &head, const Tail&... tail) { return min(head, var_min(tail...)); } template const Head& var_max(const Head &head, const Tail&... tail) { return max(head, var_max(tail...)); } template void chmin(T &t, const Tail&... tail) { t = var_min(t, tail...); } template void chmax(T &t, const Tail&... tail) { t = var_max(t, tail...); } void debug_func_preffix(const string &s) { if(s.size()) cout << s << " = "; } template void debug_func(const T &t, const string &s = "") { debug_func_preffix(s); cout << t << DEBUG_ENDL_S(s); } template void debug_func(const P &p, const string &s = "") { debug_func_preffix(s); cout << "("; debug_func(p.first); cout << ", "; debug_func(p.second); cout << ")" << DEBUG_ENDL_S(s); } template void debug_func(const V &v, const string &s = "") { for(ll i = 0; i < v.size(); i++) { string t = s + "[" + to_string(i) + "]"; debug_func(v[i], t); } } void init_io() { cin.tie(0); ios_base::sync_with_stdio(false); cout << fixed << setprecision(30); } const ll MOD = 1e9 + 7; class Combination { private: template using V = vector; ll N; ll MOD; V factv, rfactv; public: /* * MOD must be a prime number. */ Combination(ll N, ll MOD) : N(N), MOD(MOD), factv(N + 1, 1), rfactv(N + 1) { for(ll i = 1; i <= N; i++) { factv[i] = factv[i - 1] * i % MOD; } for(ll i = 0; i <= N; i++) { rfactv[i] = pow(factv[i], MOD - 2); } } ll fact(ll n) { return factv[n]; } ll rfact(ll n) { return rfactv[n]; } ll pow(ll a, ll b) { return b ? (b & 1 ? a : 1) * pow(a * a % MOD, b / 2) % MOD : 1; } ll comb(ll n, ll k) { return factv[n] * rfactv[n - k] % MOD * rfactv[k] % MOD; } }; Combination comb(1e6 + 3e5 + 10, MOD); ll N, M, D1, D2; ll distr; ll calc(ll n) { if(n > N - 1) return 0; ll rest = distr - (D2 - D1 + 1) * n; if(rest < 0) return 0; ll ret = comb.comb(rest + N, N) * comb.comb(N - 1, n) % MOD; ((ret -= calc(n + 1)) += MOD) %= MOD; return ret; } int main() { init_io(); cin >> N >> M >> D1 >> D2; distr = M - 1 - D1 * (N - 1); if(distr < 0) { cout << 0 << endl; return 0; } cout << calc(0) << endl; return 0; }