#include<bits/stdc++.h>
#define ll long long
#define mod 1000000007
#define N 200005
using namespace std;
 
int n,t,x,y,cnt,tot,fac[N],inv[N],ans,mn[N],a[N],b[N],c[N],sz[N],sum[N],m,mm;
int main(){
	scanf("%d%d%d",&n,&x,&y);
	int i;
	memset(mn,60,sizeof(mn));
	for (i=1,m=mm=1010000000; i<=n; i++){
		scanf("%d%d",&a[i],&b[i]);
		mn[a[i]]=min(mn[a[i]],b[i]);
		if (b[i]<m){
			m=b[i]; t=a[i];
		}
	}
	for (i=1; i<=n; i++) if (a[i]!=t && b[i]<mm) mm=b[i];
	for (i=1; i<=n; i++) if (b[i]+mn[a[i]]<=x) sz[a[i]]++;
	for (i=1; i<=n; i++) if (b[i]+m<=y && a[i]!=t || b[i]+mm<=y) sum[a[i]]++;
	for (i=1; i<=n; i++) if (sum[i] || i==t){
		c[++cnt]=max(sum[i],sz[i]);
		tot+=c[cnt];
	}
	fac[0]=inv[0]=inv[1]=1;
	for (i=1; i<=n; i++) fac[i]=(ll)fac[i-1]*i%mod;
	for (i=2; i<=n; i++) inv[i]=mod-(ll)inv[mod%i]*(mod/i)%mod;
	for (i=2; i<=n; i++) inv[i]=(ll)inv[i-1]*inv[i]%mod;
	for (i=ans=1; i<=cnt; i++){
		ans=(ll)ans*fac[tot]%mod*inv[c[i]]%mod*inv[tot-c[i]]%mod; tot-=c[i];
	}
	printf("%d\n",ans);
	return 0;
}