#include <bits/stdc++.h>
using namespace std;
#define LL long long
#define MOD 1000000007
#define rep(i,x,y) for(int i=(x);i<=(y);++i)
#define drep(i,x,y) for(int i=(x);i>=(y);--i)
inline int read(){
	char ch=getchar();int x=0,f=1;
	while(ch<'0'||ch>'9'){
		if(ch=='-')f=-1;
		ch=getchar();
	}
	while('0'<=ch&&ch<='9'){
		x=x*10+ch-'0';
		ch=getchar();
	}
	return x*f;
}
int cnt[200010];
int mn[200010];
int c[200010],w[200010];
int fac[200010],inv[200010];
inline int C(int x,int y){
	return 1ll*fac[x]*inv[y]%MOD*inv[x-y]%MOD;
} 
int main(){
	int n=read(),X=read(),Y=read();
	fac[0]=1;inv[0]=inv[1]=1;
	rep(i,1,n){
		fac[i]=1ll*fac[i-1]*i%MOD;
		if(i>1){
			inv[i]=1ll*(MOD-MOD/i)*inv[MOD%i]%MOD;
		}
	}
	rep(i,2,n){
		inv[i]=1ll*inv[i-1]*inv[i]%MOD;
	}
	rep(i,1,n)mn[i]=1e9;
	rep(i,1,n){
		c[i]=read(),w[i]=read();
		mn[c[i]]=min(mn[c[i]],w[i]);
		++cnt[c[i]];
	}
	int m=1;
	rep(i,1,n){
		if(mn[i]<mn[m])m=i;
	}
	int t=1;
	rep(i,1,n){
		if(mn[i]!=1e9&&i!=m){
			if(t==-1)t=i;
			else if(mn[i]<mn[t]){
				t=i;
			}
		}
	}
	//printf("%d %d\n",mn[m],mn[t]);
	rep(i,1,n){
		if(w[i]!=mn[c[i]]&&w[i]+mn[c[i]]<=X)continue;
		if(c[i]==m&&w[i]+mn[t]<=Y)continue;
		if(c[i]!=m&&w[i]+mn[m]<=Y)continue;
		--cnt[c[i]];
	}
	//rep(i,1,n)printf("%d\n",cnt[i]);
	int sum=0;
	rep(i,1,n){
		if(mn[i]!=1e9&&(i==m||mn[i]+mn[m]<=Y)){
			sum+=cnt[i];
		}
	}
	int ans=1;
	rep(i,1,n){
		if(mn[i]!=1e9&&(i==m||mn[i]+mn[m]<=Y)){
			ans=1ll*ans*C(sum,cnt[i])%MOD;
			sum-=cnt[i];
		}
	}
	printf("%d\n",ans);
}
