#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <queue>
#include <vector>
#include <bitset>
#include <string>
#include <cmath>
#include <set>
#include <map>
#define Rep(i, x, y) for (int i = x; i <= y; i ++)
#define Dwn(i, x, y) for (int i = x; i >= y; i --)
#define RepE(i, x) for (int i = pos[x]; i; i = g[i].nex)
#define ev g[i].y
using namespace std;
typedef long long ll;
typedef double db;
const int N = 200010, mod = 1e9 + 7;
int n, X, Y, b[N], a[N], c[N], w[N], sum, inf, m1, m2;
ll ans, fac[N], inv[N];
ll mypow(ll x, int y) {
	ll z = 1;
	while (y) {
		if (y & 1) (z *= x) %= mod;
		y >>= 1; (x *= x) %= mod;
	}
	return z;
}
int main()
{
	scanf ("%d%d%d", &n, &X, &Y);
	fac[0] = 1;
	Rep(i, 1, n) fac[i] = fac[i - 1] * i % mod;
	inv[n] = mypow(fac[n], mod - 2);
	Dwn(i, n, 1) inv[i - 1] = inv[i] * i % mod;
	inf = max(X, Y) + 1;
	Rep(i, 0, n) b[i] = inf;
	Rep(i, 1, n) {
		scanf ("%d%d", &c[i], &w[i]);
		b[ c[i] ] = min(b[ c[i] ], w[i]);
	}
	Rep(i, 1, n) {
		if (b[i] < b[m1]) m2 = m1, m1 = i;
		else if (b[i] < b[m2]) m2 = i;
	}
	Rep(i, 1, n) {
		if (c[i] == m1) {
			if ((m2 && w[i] + b[m2] <= Y) || w[i] + b[m1] <= X) {
				sum ++, a[ c[i] ] ++;
			}
		} else {
			if ((w[i] + b[ c[i] ] <= X && b[ c[i] ] + b[m1] <= Y) || w[i] + b[m1] <= Y) {
				sum ++, a[ c[i] ] ++;
			}
		}
	}
	// Rep(i, 1, n) if (a[i]) {}
	ans = fac[sum];
	Rep(i, 1, n) ans = ans * inv[ a[i] ] % mod;
	printf("%lld\n", ans);

	return 0;
}