/*Program from Luvwgyx*/
#include<vector>
#include<cstdio>
#include<cstring>
#include<algorithm>
#define int long long
using namespace std;
const int mod=1e9+7;
const int maxn=2e5+10;
int n,X,Y,c[maxn],w[maxn],mn[maxn],cnt[maxn],fac[maxn],inv[maxn];
int read(){
    int x=0,f=1;char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
    return x*f;
}
void print(int x){
    if(x<0)putchar('-'),x=-x;
    if(x>9)print(x/10);
    putchar(x%10+'0');
}
void write(int x){print(x);puts("");}
int power(int a,int b){
    int ret=1;
    for(;b;b>>=1,a=a*a%mod)
        if(b&1)ret=ret*a%mod;
    return ret;
}
void init(){
    memset(mn,63,sizeof(mn));
    fac[0]=1;for(int i=1;i<=n;i++)fac[i]=fac[i-1]*i%mod;
    inv[n]=power(fac[n],mod-2);inv[0]=1;
    for(int i=n-1;i>=1;i--)inv[i]=inv[i+1]*(i+1)%mod;
}
signed main(){
    n=read();X=read();Y=read();init();
    for(int i=1;i<=n;i++){
        c[i]=read();w[i]=read();
        mn[c[i]]=min(mn[c[i]],w[i]);
    }int Min=0,Minn=0;
    for(int i=1;i<=n;i++){
        if(mn[i]<mn[Min]){Minn=Min;Min=i;}
        else if(mn[i]<mn[Minn])Minn=i;
    }int sum=0,ans=1;
    for(int i=1;i<=n;i++){
        if(w[i]+mn[c[i]]<=X)w[i]=mn[c[i]];
        if(c[i]!=Min&&mn[Min ]+w[i]<=Y)cnt[c[i]]++;
        if(c[i]==Min&&mn[Minn]+w[i]<=Y)cnt[c[i]]++;
    }for(int i=1;i<=n;i++)if(cnt[i])sum+=cnt[i],ans=ans*inv[cnt[i]]%mod;
    write(ans*fac[sum]%mod);
    return 0;
}
