#include <bits/stdc++.h>
using namespace std;
const long long Mo = 1000000007LL;
int n, top;
vector<int> vec[201000];
int CNT[201000], cnt[201000];
long long fac[201000], inv[201000];
int x, y;
long long ans;
long long fpm(long long a, long long b) {
  if (!a) return 0LL;
  long long ans = 1LL;
  for (; b; b >>= 1) {
    if (b & 1) ans *= a, ans %= Mo;
    a *= a;
    a %= Mo;
  }
  return ans;
}
long long C(int a, int b) { return fac[a] * inv[b] % Mo * inv[a - b] % Mo; }
int main() {
  scanf("%d %d %d", &n, &x, &y);
  fac[0] = 1;
  for (int i = 1; i <= n; i++) fac[i] = fac[i - 1] * (long long)i % Mo;
  inv[n] = fpm(fac[n], Mo - 2LL);
  for (int i = n; i >= 1; i--) inv[i - 1] = inv[i] * (long long)i % Mo;
  for (int i = 1; i <= n; i++) {
    int c, w;
    scanf("%d %d", &c, &w);
    vec[c].push_back(w);
  }
  for (int i = 1; i <= n; i++) sort(vec[i].begin(), vec[i].end());
  int just = 1 << 30;
  for (int i = 1; i <= n; i++) {
    for (auto j = vec[i].begin(); j != vec[i].end(); j++)
      if (vec[i][0] + *j <= x || j == vec[i].begin()) cnt[i]++;
    if (!vec[i].empty()) just = min(just, vec[i][0]);
  }
  for (int i = 1; i <= n; i++) {
    if (vec[i].empty()) continue;
    if (vec[i][0] + just <= y) CNT[++top] = cnt[i];
  }
  for (int i = 1; i <= top; i++) CNT[i] += CNT[i - 1];
  ans = 1LL;
  for (int i = top; i >= 1; i--) (ans *= C(CNT[i], CNT[i - 1])) %= Mo;
  cout << ans << endl;
  return 0;
}
