#include<bits/stdc++.h>
using namespace std;
const int mod=1e9+7;
int qpow(int x,int k)
{
    int r=1;
    while(k)
    {
        if(k&1)r=1ll*r*x%mod;
        k>>=1;x=1ll*x*x%mod;
    }
    return r;
}
int n,X,Y;
struct Ball{
    int c,w;
}b[200200];
int mi[200200];
int ami,amc;
int cmi;
bool av[200200];
int tot;
int cnt[200200];
int fac[200200],ifac[200200];
int main()
{
    scanf("%d%d%d",&n,&X,&Y);
    memset(mi,0x3f,sizeof(mi));
    ami=mi[0];
    for(int i=1;i<=n;++i)
    {
        scanf("%d%d",&b[i].c,&b[i].w);
        mi[b[i].c]=min(mi[b[i].c],b[i].w);
        if(mi[b[i].c]<ami)
            ami=mi[b[i].c],amc=b[i].c;
    }
    cmi=mi[0];
    for(int i=1;i<=n;++i)
        if(b[i].c!=amc)cmi=min(cmi,b[i].w);
    for(int i=1;i<=n;++i)
        if(mi[i]+ami<=Y)av[i]=1;
    av[amc]=1;
    for(int i=1;i<=n;++i)
    {
        if(!av[b[i].c])continue;
        cnt[b[i].c]++;tot++;
        if(b[i].w+mi[b[i].c]<=X||b[i].w==mi[b[i].c])
            continue;
        if(b[i].c!=amc&&b[i].w+ami<=Y)continue;
        if(b[i].c==amc&&b[i].w+cmi<=Y)continue;
        cnt[b[i].c]--;tot--;
    }
    fac[0]=1;
    for(int i=1;i<=n;++i) fac[i]=1ll*fac[i-1]*i%mod;
    ifac[n]=qpow(fac[n],mod-2);
    for(int i=n-1;i>=0;--i)ifac[i]=1ll*ifac[i+1]*(i+1)%mod;
    int ans=fac[tot];
    for(int i=1;i<=n;++i)
        ans=1ll*ans*ifac[cnt[i]]%mod;
    printf("%d\n",ans);
    return 0;
}
