#include<bits/stdc++.h>
#define L long long
using namespace std;
const int q=1000000007;
int n,x,y,a[200010],b[200010],w[200010],u,v,r,f[200010],g,c[200010],d[200010],p;
int main()
{
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	int i;
	scanf("%d%d%d",&n,&x,&y);
	c[0]=1;
	u=2e9;
	for(i=1;i<=n;i++)
	  {
	   c[i]=(L)c[i-1]*i%q;
	   w[i]=2e9;
      }
    d[0]=d[1]=1;
    for(i=2;i<=n;i++)
      d[i]=q-(L)q/i*d[q%i]%q;
    for(i=2;i<=n;i++)
      d[i]=(L)d[i]*d[i-1]%q;
	for(i=1;i<=n;i++)
	  {
	   scanf("%d%d",&a[i],&b[i]);
	   if(b[i]<u)
	     r=u,u=b[i],v=a[i];
	   else
	     r=min(r,b[i]);
	   w[a[i]]=min(w[a[i]],b[i]);
      }
    for(i=1;i<=n;i++)
      if(b[i]+w[a[i]]<=x && w[a[i]]+u<=y || a[i]!=v && b[i]+u<=y || b[i]+r<=y)
        {
         f[a[i]]++;
         g++;
        }
    p=c[g];
    for(i=1;i<=n;i++)
      p=(L)p*d[f[i]]%q;
    printf("%d\n",p);
	return 0;
}
