#include <bits/stdc++.h>
using namespace std;

typedef pair <int,int>  PII;
const int mo=int(1e9+7);
struct node{int c,w;}a[200010];
int n,X,Y,m1,m2,fac[200010],mn[200010],tot,mul;

bool cmp(node x,node y){return (x.c<y.c)||((x.c==y.c)&&(x.w<y.w));}

int qpow(int a,int b)
{
	int x=a;  a=1;
	while (b)
		{
			if (b&1)  a=1LL*a*x%mo;
			x=1LL*x*x%mo,b>>=1;
		}
	return a;
}

void work()
{
	scanf("%d %d %d",&n,&X,&Y),fac[0]=1,mul=1,m1=m2=Y;
	for (int i=1; i<=n; i++)
		{
			scanf("%d %d",&a[i].c,&a[i].w);
			if (a[i].w<m2)  m2=a[i].w;
			if (m2<m1)  swap(m1,m2);
		}
	for (int i=1; i<=n; i++)  fac[i]=1LL*fac[i-1]*i%mo;
	sort(a+1,a+n+1,cmp),a[n+1].w=Y;
	if (m1+m2>Y)  puts("1"),exit(0);
	for (int i=1,j=0,k=0,p; i<=n+1; i++)
		{
			if (a[i].c!=a[j].c)  mul=1LL*mul*fac[k]%mo,j=i,k=0,p=0;
			if (a[j].w!=m1)
				{
					if ((a[i].w+m1<=Y)||((p)&&(a[j].w+a[i].w<=X)))  tot++,k++,p=1;
				}else  if ((a[i].w+m1<=X)||(a[i].w+m2<=Y))  tot++,k++;
		}
	printf("%d",int(1LL*fac[tot]*qpow(mul,mo-2)%mo));
	
}

int main()
{
	work();
	return 0;
}
