#include<bits/stdc++.h>
using namespace std;
const int P=1e9+7,N=2e5+7;
int c[N],w[N],d[N],f[N],iv[N],fc[N],fciv[N];
int main(){
	int n,x,y,i,j,t=0,mn=2e9,mn2=2e9,ans=1;
	scanf("%d%d%d",&n,&x,&y);
	memset(d,63,n+1<<2);
	for(i=1;i<=n;++i)scanf("%d%d",c+i,w+i),d[c[i]]=min(d[c[i]],w[i]);
	for(i=1;i<=n;++i)if(d[i]<mn)mn2=mn,mn=d[i];else if(d[i]<mn2)mn2=d[i];
	if(mn+mn2>y)return puts("1"),0;
	fc[1]=iv[1]=fciv[1]=1;
	for(i=2;i<=n;++i)iv[i]=(P-P/i)*1ll*iv[P%i]%P,fc[i]=fc[i-1]*1ll*i%P,fciv[i]=fciv[i-1]*1ll*iv[i]%P;
	for(i=1;i<=n;++i)if((w[i]+d[c[i]]<=x)||(w[i]+(d[c[i]]==mn?mn2:mn)<=y))++f[c[i]];
	for(i=1;i<=n;++i)if(d[i]+mn<=y)t+=f[i],ans=ans*1ll*fciv[f[i]]%P;
	printf("%d",ans*1ll*fc[t]%P);
	return 0;
}