#include<cstdio>
#include<algorithm>
#define rep(i,s,t) for(register int i=s;i<=t;++i)
#define _rep(i,s,t) for(register int i=s;i>=t;--i)
using namespace std;
const int N=1e6+11,inf=2147483647,mod=1e9+7;
int a[N],w[N],mn[N],fac[N],ifac[N],cnt[N];
int n,x,y,m,t=inf,ans,num;
inline int fp(int a,int b){
	int res=1;
	for(;b;b>>=1,a=1ll*a*a%mod)
		if(b&1)
			res=1ll*res*a%mod;
	return res;
}
inline int C(int n,int m){
	return 1ll*fac[n]*ifac[n-m]%mod*ifac[m]%mod;
}
int main(){
	scanf("%d%d%d",&n,&x,&y);
	fac[0]=1;
	rep(i,1,n)
		fac[i]=1ll*i*fac[i-1]%mod;
	ifac[n]=fp(fac[n],mod-2);
	_rep(i,n,1)
		ifac[i-1]=1ll*i*ifac[i]%mod;
	rep(i,1,n)
		mn[i]=inf;
	rep(i,1,n){
		scanf("%d%d",a+i,w+i);
		mn[a[i]]=min(mn[a[i]],w[i]);
		++cnt[a[i]];
	}
	m=1;
	rep(i,1,n)
		if(mn[i]<mn[m])
			m=i;
	rep(i,1,n)
		if(m!=i&&t>mn[i])
			t=mn[i];
	rep(i,1,n){
        if(w[i]!=mn[a[i]]&&w[i]+mn[a[i]]<=x)continue;
        if(a[i]!=m&&w[i]+mn[m]<=y)continue;
        if(a[i]==m&&w[i]+t<=y)continue;
        --cnt[a[i]];
    }
    num=cnt[m];
    rep(i,1,n)
        if(mn[i]!=inf&&i!=m)
            if(mn[i]+mn[m]<=y)
				num+=cnt[i];
    ans=1;
    rep(i,1,n)
        if(mn[i]!=inf&&(i==m||mn[i]+mn[m]<=y)){
            ans=1ll*ans*C(num,cnt[i])%mod;
            num-=cnt[i];
        }
    printf("%d\n",ans);
	return 0;
}