#include <bits/stdc++.h>
const int N = 2e5 + 3, M = 1e9 + 7;
int n, x, y, a, b, ans, sum, t[N], invf[N], c[N], d, f[N];
std::vector<int> h[N];
bool Cmp(const int& i, const int& j) {
  if (!h[i].size()) return 0;
  if (!h[j].size()) return 1;
  return h[i][0] < h[j][0];
}
inline int Pow(int a, int m) {
  int s = 1;
  for (; m; m >>= 1) m& 1 ? s = 1ll * s * a % M : 0, a = 1ll * a * a % M;
  return s;
}
void InC() {
  f[0] = 1;
  for (int i = 1; i <= n; i++) f[i] = 1ll * f[i - 1] * i % M;
  invf[n] = Pow(f[n], M - 2);
  for (int i = n; i; i--) invf[i - 1] = 1ll * invf[i] * i % M;
}
inline int C(int n, int m) {
  return 1ll * f[n] * invf[m] % M * invf[n - m] % M;
}
int main() {
  scanf("%d%d%d", &n, &x, &y);
  InC();
  for (int i = 1; i <= n; i++)
    scanf("%d%d", &a, &b), h[a].push_back(b), t[i] = i;
  for (int i = 1; i <= n; i++) {
    std::sort(h[i].begin(), h[i].end());
    for (int j = 1; j < h[i].size(); j++)
      if (h[i][0] + h[i][j] <= x) c[i] = j;
  }
  std::sort(t + 1, t + 1 + n, Cmp);
  if (!h[t[2]].size()) return 0 * puts("1");
  for (int i = 1, k; h[t[i]].size(); i++) {
    k = i == 1 ? 2 : 1;
    for (int j = 0; j < h[t[i]].size(); j++)
      if (h[t[k]][0] + h[t[i]][j] <= y && j > c[t[i]]) c[t[i]] = j;
    if (h[t[i]][0] + h[t[k]][0] <= y) d = i;
  }
  ans = 1;
  sum = 0;
  for (int i = 1; i <= d; i++) sum += c[t[i]] + 1;
  for (int i = 1; i <= d; i++)
    ans = 1ll * ans * C(sum, c[t[i]] + 1) % M, sum -= c[t[i]] + 1;
  printf("%d", ans);
  return 0;
}
