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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcount

#define INF 1e16
#define mod 1000000007

ll fac[200010],finv[200010];

ll mod_pow(ll a,ll n){
  ll res=1;
  while(n>0){
    if(n&1)res=res*a%mod;
    a=a*a%mod;
    n>>=1;
  }
  return res;
}

ll N,X,Y;
ll c[200010],w[200010];
ll cnt[200010];
vector<P> ps[200010];

int main(){
  fac[0]=1;
  rep(i,200000)fac[i+1]=fac[i]*(i+1)%mod;
  rep(i,200001)finv[i]=mod_pow(fac[i],mod-2);

  cin>>N>>X>>Y;
  rep(i,N){
    cin>>c[i]>>w[i];
    c[i]--;
  }
  rep(i,N){
    ps[c[i]].push_back(P(w[i],i));
  }
  rep(i,N){
    if(ps[i].size()==0)continue;
    sort(all(ps[i]));
    ll mn=ps[i][0].fi;
    repl(j,1,ps[i].size()){
      if(ps[i][j].fi<=X-mn)w[ps[i][j].se]=mn;
    }
  }
  ll mnidx=0;
  rep(i,N){
    if(w[mnidx]>w[i])mnidx=i;
  }
  ll mn2=INF;
  rep(i,N){
    if(c[i]==c[mnidx])continue;
    minch(mn2,w[i]);
  }
  if(w[mnidx]+mn2>Y){
    cout<<1<<endl;
    return 0;
  }

  ll sum=0;
  rep(i,N){
    if(c[i]==c[mnidx]){
      if(w[i]<=Y-mn2){
        cnt[c[i]]++;
        sum++;
      }
    }else{
      if(w[i]<=Y-w[mnidx]){
        cnt[c[i]]++;
        sum++;
      }
    }
  }
  ll res=fac[sum];
  rep(i,N)(res*=finv[cnt[i]])%=mod;
  cout<<res<<endl;

  return 0;
}
