#include <cstdio>
#include <map>
#include <algorithm>

typedef long long i64;

const int N = 200000 + 10, MOD = 1000000007;

int fact[N], ifact[N];

int n, x, y, c[N], w[N];

int anc[N];

int find(int x) { return anc[x] == x ? x : (anc[x] = find(anc[x])); }
inline void meld(int x, int y) { anc[find(x)] = find(y); }

std::map<int, int> cnt[N];

int main() {
  fact[0] = 1;
  for (int i = 1; i < N; ++i) fact[i] = (i64)fact[i - 1] * i % MOD;
  ifact[1] = 1;
  for (int i = 2;   i < N; ++i) ifact[i] = ((i64)MOD - MOD / i) * ifact[MOD % i] % MOD;
  ifact[0] = 1;
  for (int i = 1; i < N; ++i) ifact[i] = (i64)ifact[i - 1] * ifact[i] % MOD;
  scanf("%d%d%d", &n, &x, &y);
  static int min[N];
  for (int i = 1; i <= n; ++i) scanf("%d%d", &c[i], &w[i]), anc[i] = i;
  for (int i = 1; i <= n; ++i) if (!min[c[i]] || w[min[c[i]]] > w[i]) min[c[i]] = i;
  for (int i = 1; i <= n; ++i) if (w[i] + w[min[c[i]]] <= x) meld(min[c[i]], i);
  int p = std::min_element(w + 1, w + n + 1) - w, q = 0;
  for (int i = 1; i <= n; ++i) if (c[i] != c[p] && (!q || w[q] > w[i])) q = i;
  for (int i = 1; i <= n; ++i) {
    if (c[i] != c[p] && w[i] + w[p] <= y) meld(i, p);
    if (c[i] != c[q] && w[i] + w[q] <= y) meld(i, q);
  }
  int ans = 1;
  for (int i = 1; i <= n; ++i) ++cnt[find(i)][c[i]];
  for (int i = 1; i <= n; ++i) {
    int sum = 0, cur = 1;
    for (std::map<int, int>::iterator it = cnt[i].begin(); it != cnt[i].end(); ++it) sum += it->second, cur = (i64)cur * ifact[it->second] % MOD;
    cur = (i64)cur * fact[sum] % MOD;
    ans = (i64)ans * cur % MOD;
  }
  printf("%d\n", ans);
  return 0;
}
