#include <bits/stdc++.h>
#define mod 1000000007
using namespace std;
int read();
vector<int> c[200005];
int w[200005];

int fsp(int bs, int p) {
	int rt = 1;
	while (p) {
		if (p & 1) rt = 1ll * rt * bs % mod;
		bs = 1ll * bs * bs % mod, p >>= 1;
	}
	return rt;
}

int fac[200005], caf[200005];
void init(int n) {
	fac[0] = 1;
	for (int i = 1; i <= n; ++i) fac[i] = 1ll * i * fac[i - 1] % mod;
	caf[n] = fsp(fac[n], mod - 2);
	for (int i = n; i >= 1; --i) caf[i - 1] = 1ll * i * caf[i] % mod;
}

int main() { 
	int n = read(), X = read(), Y = read();
	init(n);
	for (int i = 1, tc, tw; i <= n; ++i) {
		tc = read(), tw = read();
		if (!c[tc].size()) w[tc] = tw;
		c[tc].push_back(tw), w[tc] = min(tw, w[tc]);
	}
	int mc1 = 0, mc2 = 0;
	for (int i = 1; i <= n; ++i) 
		if (c[i].size() && (!mc1 || w[i] < w[mc1])) mc1 = i;
	for (int i = 1; i <= n; ++i) 
		if (c[i].size() && i != mc1 && (!mc2 || w[i] < w[mc2])) mc2 = i;
	if (!mc2 || w[mc1] + w[mc2] > Y) return puts("1"), 0;
	int res1 = 0, res2 = 1;
	for (int i = 1, cnt; i <= n; ++i) {
		if (!c[i].size() || w[i] + w[mc1] > Y) continue;
		cnt = 0;
		for (vector<int>::iterator j = c[i].begin(); j != c[i].end(); ++j) {
			cnt += ((*j) + w[mc1 - i ? mc1 : mc2] <= Y || (*j) + w[i] <= X);
		}
		res1 += cnt, res2 = 1ll * caf[cnt] * res2 % mod;
	}
	printf("%d\n", 1ll * fac[res1] * res2 % mod);
	return 0; 
}

int read() {
    int x = 0, f = 1;
    char c = getchar();
    while (c < '0' || c > '9') f = (c == '-') ? -1 : f, c = getchar();
    while (c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
    return x * f;
}
