//Created Time:2019年12月17日 星期二 18时41分06秒
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#define N 200005
#define mod 1000000007

using namespace std;

int n, x, y, mn = 999999999, cnt;
int c[N], a[N], ifac[N], fac[N];

struct Ball{
	int col, w;
}b[N];

int read();
int quick_pow(int ,int);

int main(){
	n = read(), x = read(), y = read();
	memset(c, 127, sizeof c); fac[0] = ifac[0] = 1;
	int pos = 1, poss = 1;
	for(int i = 1; i <= n; ++i){
		int col = read(), w = read();
		c[col] = min(c[col], w); b[i] = (Ball){col, w};
		fac[i] = 1ll * fac[i - 1] * i % mod;
	}
	for(int i = 1; i <= n; ++i)
		if(c[i] < c[pos]) poss = pos, pos = i;
		else if(c[i] < c[poss]) poss = i;
	ifac[n] = quick_pow(fac[n], mod - 2);
	for(int i = n - 1; i; --i)
		ifac[i] = 1ll * ifac[i + 1] * (i + 1) % mod;
	for(int i = 1; i <= n; ++i){
		int col = b[i].col, w = b[i].w;
		if((pos != col && (w + c[pos] <= y || (w + c[col] <= x && c[col] + c[pos] <= y))) || (col == pos && (w + c[pos] <= x || (w + c[poss] <= y && c[poss] + c[pos] <= y))))
			++cnt, ++a[col];
	}
	int ans = fac[cnt];
//	cout << cnt << endl;
	for(int i = 1; i <= n; ++i)
		ans = 1ll * ans * ifac[a[i]] % mod;
	cout << ans << endl;
	return 0;
}

int read(){
	int x = 0; char ch = getchar();
	for(; !isdigit(ch); ch = getchar());
	for(; isdigit(ch); ch = getchar()) x = (x << 1) + (x << 3) + (ch ^ 48);
	return x;
}

int quick_pow(int x, int y){
	int sum = 1;
	for(; y; y >>= 1, x = 1ll * x * x % mod) if(y & 1) sum = 1ll * sum * x % mod;
	return sum;
}
