#include <cstdio>
#include <algorithm>
#define fs first
#define sc second
#define mp make_pair
#define ll long long
#define org b[1].sc
#define rep(i,j,k) for (i=j;i<=k;i++)
#define down(i,j,k) for (i=j;i>=k;i--)
using namespace std;
const int N=2e5+5,mod=1e9+7;
typedef pair<int,int> Pair;
Pair a[N],b[N];
int n,bn,col,X,Y,i,sum,ans;
int fac[N],inv[N],cnt[N],flg[N],Min[N],con[N];
int fgm(int a,int n)
{
	int ret=1,bsc=a;
	for (;n>0;n>>=1,bsc=(ll)bsc*bsc%mod)
		if (n&1) ret=(ll)ret*bsc%mod;
	return ret;
}
int main()
{
//	freopen("colorful.in","r",stdin);
//	freopen("colorful.out","w",stdout);
	
	scanf("%d%d%d",&n,&X,&Y);
	rep(i,1,n) scanf("%d%d",&a[i].sc,&a[i].fs);
	sort(a+1,a+1+n);
	rep(i,1,n)
		if (!flg[a[i].sc]) b[++bn]=a[i],Min[a[i].sc]=a[i].fs,flg[a[i].sc]=1;
	if (bn==1 || b[1].fs+b[2].fs>Y) { printf("1\n"); return 0; }
	
	rep(i,2,bn) {
		if (b[i].fs+b[1].fs>Y) break;
		con[b[i].sc]=1;
	}
	
	rep(i,1,n)
	{
		col=a[i].sc;
		if (col==org) {
			if (a[i].fs+Min[col]<=X || a[i].fs+b[2].fs<=Y) cnt[col]++;
		}
		else
		if (con[col]) {
				if (a[i].fs+Min[col]<=X || a[i].fs+Min[org]<=Y) cnt[col]++;
		}
	}
	
	fac[1]=1; rep(i,2,n) fac[i]=(ll)fac[i-1]*i%mod;
	inv[n]=fgm(fac[n],mod-2);
	down(i,n-1,1) inv[i]=(ll)inv[i+1]*(i+1)%mod;
	
	ans=1;
	rep(i,1,n)
		if (cnt[i]) sum+=cnt[i],ans=(ll)ans*inv[cnt[i]]%mod;
	ans=(ll)ans*fac[sum]%mod;
	printf("%d\n",ans);
	return 0;
}