// Slower C++ solution:
#include<iostream>

#include<cstdio>

#include<cstdlib>

#include<cmath>

#include<cstring>

#include<algorithm>

#include<vector>

#define ll long long

#define re register

#define il inline

#define pb push_back

#define fp(i,a,b) for(re int i=a;i<=b;++i)

#define fq(i,a,b) for(re int i=a;i>=b;--i)

using namespace std;

const int N=2e5+100,mod=1e9+7;

int n,x,X,Y,mn[N],mn1=mod,mn2=mod,ans=1,inv[N],tot;

vector<int>V[N];

il ll gi()

{

  re ll x=0,t=1;

  re char ch=getchar();

  while(ch!='-'&&(ch<'0'||ch>'9')) x=x*10+ch-48,ch=getchar();

  if(ch=='-') t=-1,ch=getchar();

  while(ch>='0'&&ch<='9') x=x*10+ch-48,ch=getchar();

  return x*t;

}

int main()

{

  n=gi();X=gi();Y=gi();

  inv[0]=inv[1]=1;

  fp(i,1,n) x=gi(),V[x].pb(gi());

  fp(i,2,n) inv[i]=1ll*(mod-mod/i)*inv[mod%i]%mod;

  fp(i,2,n) inv[i]=1ll*inv[i]*inv[i-1]%mod;

  fp(i,1,n)

    if(V[i].size())

      {

	sort(V[i].begin(),V[i].end());

        mn2=min(mn2,mn[i]=V[i][0]);

	if(mn2<mn1) swap(mn1,mn2);

      }

    else mn[i]=mod;

  fp(i,1,n)

    {

      re int mm=(mn[i]==mn1?mn2:mn1),sz=V[i].size();

      while(sz>1&&V[i][sz-1]+mm>Y&&V[i][sz-1]+mn[i]>X) --sz;

      if(mm+mn[i]<=Y) ans=1ll*ans*inv[sz]%mod,tot+=sz;

    }

  fp(i,1,tot) ans=1ll*ans*i%mod;

  printf("%d\n",ans);

  return 0;

}


// Faster C++ solution for the same problem (measured speedup: 6.572163609569249x):
#include<bits/stdc++.h>

#define re register

#define For(i, j, k) for(re int i = j; i <= k; i++)

#define foR(i, j, k) for(re int i = j; i >= k; i--)

#define Cross(i, j, k) for(re int i = j; i; i = k)

#define debug(x) (cout << "#x = " << x << endl)

using namespace std;

typedef long long ll;

const ll N = 200011;

const ll p = 1e9 + 7;

const ll inf = 0x3f3f3f3f3f3f;



ll n, A, B, c[N], w[N];



namespace IO {



	#define dd (ch = getchar())

	inline ll read() {

		ll x = 0; bool f = 0; char ch = getchar();

		for (; !isdigit (ch); dd) f ^= (ch == '-');

		for (; isdigit (ch); dd)  x = (x << 1) + (x << 3) + (ch ^ 48);

		return f? -x: x;

	}

	#undef dd

	

	inline void write ( ll x ) {

		if ( x < 0 ) x = -x, putchar ('-');

		if ( x > 9 ) write ( x / 10 );

		putchar ( x % 10 | 48 );

	}

	

	inline void wrn ( ll x ) { write (x); putchar (' '); }

	

	inline void wln ( ll x ) { write (x); putchar ('\n'); }

	

	inline void wlnn ( ll x, ll y ) { wrn (x); wln (y); }



}



using namespace IO;



namespace Subtask1 {

	

	ll ans = 0;

	

	inline void dfs ( ll now, ll pos ) {

		if ( now == n + 1 || pos == n + 1 ) return ;

		if ( c[now] != c[pos] && w[now] + w[pos] <= B ) ans++;

		if ( ans == p ) ans = 0;

		dfs ( now, pos + 1 ); 

		if ( now != pos ) dfs ( now + 1, pos + 1 );

	}

	

	inline void main () {

		dfs ( 1, 1 );

		wln (ans + 3); exit (0);

	}

	

}



namespace Subtask2 {

	

	inline void main () {

		puts("1"); exit (0);

	}

	

}



namespace Subtask3 {

	

	ll m, mn[N], fac[N], inv[N], cnt[N];

	

	inline ll power ( ll a, ll b ) {

		ll res = 1;

		for (; b; b >>= 1, a = a * a % p) res = (b & 1)? res * a % p: res;

		return res;

	}

	

	inline ll C ( ll n, ll m ) {

		if ( n < m || m < 0 ) return 0;

		return fac[n] * inv[m] % p * inv[n - m] % p;

	}

	

	inline void Init() {

		For ( i, 1, n ) mn[i] = inf;

		fac[0] = 1;

		For ( i, 1, n ) fac[i] = fac[i - 1] * i % p;

		inv[n] = power ( fac[n], p - 2 );

		foR ( i, n - 1, 0 ) inv[i] = inv[i + 1] * (i + 1) % p;

		For ( i, 1, n )

			cnt[c[i]]++, mn[c[i]] = min ( w[i], mn[c[i]] );

	}

	

	inline void main () {

		Init();

		For ( i, 1, n ) if ( mn[i] != inf ) 

			if ( m == 0 || mn[i] < mn[m] ) m = i;

		ll t = inf;

		For ( i, 1, n ) 

			if ( mn[i] != inf && i != m ) t = min ( t, mn[i] );

		For ( i, 1, n ) 

			if ( (w[i] == mn[c[i]] || 

				w[i] + mn[c[i]] > A) 

					&& (c[i] == m || w[i] + mn[m] > B) 

						&& (c[i] != m || w[i] + t > B) ) cnt[c[i]]--;

		ll num = cnt[m];

		For ( i, 1, n )

			if ( mn[i] != inf && i != m )

				if ( mn[i] + mn[m] <= B ) num += cnt[i];

		ll ans = 1;

		For ( i, 1, n ) if ( mn[i] != inf 

			&& (i == m || mn[i] + mn[m] <= B) )

				ans = ans * C(num, cnt[i]) % p, num -= cnt[i];

		wln (ans); exit (0);

	}

	

}



ll f = 1;



int main() {

//	freopen("keep.in", "r", stdin);

//	freopen("keep.out", "w", stdout);

	n = read(), A = read(), B = read();

	For ( i, 1, n ) {

		c[i] = read(), w[i] = read();

		if ( c[i] != c[1] ) f = 0;

	}

//	if ( n <= 20 ) 

//				Subtask1::main ();

	if (f) 	Subtask2::main ();

	else 	Subtask3::main (); return 0;

}



/*

4 7 3

3 2

4 3

2 1

4 4



2



1 1 1

1 1



1

*/