#include<set>
#include<map>
#include<cmath>
#include<queue>
#include<bitset>
#include<string>
#include<cstdio>
#include<cctype>
#include<cassert>
#include<cstdlib>
#include<cstring>
#include<sstream>
#include<iostream>
#include<algorithm>

#define For(i,x,y) for (int i=x;i<y;i++)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define lf else if

#define dprintf(...) fprintf(stderr,__VA_ARGS__)
using namespace std;

typedef long long ll;
typedef double db;
typedef pair<int,int> pii;
typedef vector<int> Vi;

int IN(){
	int c,f,x;
	while (!isdigit(c=getchar())&&c!='-');c=='-'?(f=1,x=0):(f=0,x=c-'0');
	while (isdigit(c=getchar())) x=(x<<1)+(x<<3)+c-'0';return !f?x:-x;
}

const int N=200000+19;
const int p=1e9+7;
const int oo=(1<<30)-1;

int Pow(int a,int b){
	int res=1;
	for (;b;b>>=1,a=1ll*a*a%p) if (b&1) res=1ll*res*a%p;
	return res;
}

int c[N],w[N],mn[N],wei[N],fac[N],inv[N],val[N];
int X,Y,amn,n,ans,m,id,ase;

int main(){
	//freopen("1.in","r",stdin);
	fac[0]=1;
	For(i,1,N) fac[i]=1ll*fac[i-1]*i%p;
	inv[N-1]=Pow(fac[N-1],p-2);
	for (int i=N-1;i;i--) inv[i-1]=1ll*inv[i]*i%p;
	amn=oo;ase=oo;
	For(i,0,N) mn[i]=oo;
	n=IN(),X=IN(),Y=IN();
	For(i,1,n+1){
		c[i]=IN(),w[i]=IN();
		if (w[i]<amn){
			ase=amn;
			amn=w[i];
			id=c[i];
		} lf (w[i]<ase){
			ase=w[i];
		}
		mn[c[i]]=min(mn[c[i]],w[i]);
	}
	For(i,1,n+1)
		if (c[i]==id){
			if (w[i]+amn<=X&&amn+ase<=Y||w[i]+ase<=Y){
				m++;
				val[c[i]]++;
			}
		} else{
			if (w[i]+amn<=Y||w[i]+mn[c[i]]<=X&&mn[c[i]]+amn<=Y){
				m++;
				val[c[i]]++;
			}
		}
	ans=fac[m];
	For(i,0,N) ans=1ll*ans*inv[val[i]]%p;
	printf("%d\n",ans);
}