#include <bits/stdc++.h> using namespace std; #define fo(i, a, b) for(int i = a; i <= b; i++) #define _fo(i, a, b) for(int i = a; i >= b; i--) #define foa(i, a) for (auto &i : a) #define sz(a) ((int) a.size()) #define all(a) begin(a), end(a) #define fi first #define se second #define pb(x) push_back(x) #define mk(x, y) make_pair(x, y) typedef unsigned long long ull; typedef long long ll; typedef pair<ll, ll> pll; typedef vector<ll> vl; typedef pair<int, int> pii; typedef vector<int> vi; const int N = 2e5+5; const int COMB = 2e6+5; const int LOG = 20; const ll MOD = 1e9+7; const ll INF = 1e9+1; const int SQRT = 44721; ll add(ll a, ll b) { return (a+b) % MOD; } ll sub(ll a, ll b) { return (a-b+MOD) % MOD; } ll mul(ll a, ll b) { return (a % MOD)*(b % MOD) % MOD; } int n, m; int a[N]; int x, y, w, h; vector<vector<int>> bounding_box, f; int fac[COMB], infac[COMB]; int inv(int val) { int curr = 1, temp = MOD-2; while(temp > 0) { if(temp & 1) curr = mul(curr, val); val = mul(val, val); temp >>= 1; } return curr; } void precompute() { fac[0] = 1; fo(i, 1, COMB-1) fac[i] = mul(i, fac[i-1]); infac[COMB-1] = inv(fac[COMB-1]); _fo(i, COMB-2, 0) infac[i] = mul(i+1, infac[i+1]); } void decode() { w = 0; h = 0; fo(i, 1, n) { w = max(w, a[i] / m); h = max(h, a[i] % m); } bounding_box.assign(w+1, vector<int>(h+1, 0)); fo(i, 1, n) bounding_box[a[i] / m][a[i] % m] = 1; } int comb(int a, int b) { if(b > a || b < 0) return 0; return mul(mul(fac[a], infac[a-b]), infac[b]); } int solve() { int invalid = 0; f.assign(w+1, vector<int>(h+1, 0)); f[0][0] = 1; fo(i, 0, w) { fo(j, 0, h) { if(i != 0) f[i][j] = add(f[i][j], f[i-1][j]); if(j != 0) f[i][j] = add(f[i][j], f[i][j-1]); if(bounding_box[i][j] == 1) { invalid = add(invalid, mul(f[i][j], comb(x-i+y-j, x-i))); f[i][j] = 0; } } } return sub(comb(x+y, x), invalid); } signed main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); // freopen("LANDMINE.INP", "r", stdin); // freopen("LANDMINE.OUT", "w", stdout); cin >> n >> m >> x >> y; fo(i, 1, n) cin >> a[i]; precompute(); decode(); cout << solve(); } /* 1 5 1 1 2 */