#include<cstdio>
#include<cstring>
#include<algorithm>
#include<vector>
#define N 400005
#define MOD 1000000007
#define INF 0x3f3f3f3f
#define LL long long
using namespace std;
LL c[N],w[N],col[N];
LL n,x,y,cnt;
vector<LL>a[N];
LL fac[N],ifac[N];
LL ksm(LL a,LL b)
{
	LL ans=1;
	while(b)
	{
		if(b&1) ans=ans*a%MOD;
		a=a*a%MOD;
		b>>=1;
	}
	return ans;
}
int main()
{
	scanf("%lld %lld %lld",&n,&x,&y);
	LL mminw=INF;
	int minc;
	for(int i=1;i<=n;i++)
	{
		scanf("%lld %lld",&c[i],&w[i]);
		a[c[i]].push_back(i);
		if(w[i]<mminw)
		{
			mminw=w[i];
			minc=c[i];	
		}
	}
	LL mminw1=INF;
	for(int i=1;i<=n;i++)
	{
		LL minw=INF;
		for(int j=0;j<a[i].size();j++)	
			minw=min(minw,w[a[i][j]]);
		for(int j=0;j<a[i].size();j++)
			if(w[a[i][j]]+minw<=x)
				w[a[i][j]]=minw;
		if(minc!=i)
			mminw1=min(mminw1,minw);
	}
	for(int i=1;i<=n;i++)
	{
		if(c[i]==minc)
		{
			if(w[i]+mminw1<=y)
			{
				col[c[i]]++;
				cnt++;	
			}
		}
		else if(w[i]+mminw<=y)
		{
			col[c[i]]++;
			cnt++;
		}
	}
	fac[0]=1;
	for(int i=1;i<=cnt;i++)
		fac[i]=fac[i-1]*i%MOD;
	ifac[cnt]=ksm(fac[cnt],MOD-2);
	for(int i=cnt;i>=1;i--)
		ifac[i-1]=ifac[i]*i%MOD;
	LL ans=fac[cnt];
	for(int i=1;i<=n;i++)
		ans=ans*ifac[col[i]]%MOD;
	printf("%lld",ans);
}