/*
 *Author - Abhas Jain
 *Code is inside the solve function
 */
 
#include <bits/stdc++.h>
 
#define F first
#define S second
#define all(c) c.begin(), c.end()
#define endl '\n'
#define pb push_back
#define mp make_pair 
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 
 
typedef long long ll;
typedef long double ld;

#define rep(i,a,b) for(ll i=a;i<b;i++)
#define bac(i,a,b) for(ll i=a;i>=b;i--)

 
using namespace std;
using namespace __gnu_pbds;
template <typename A, typename B>
string to_string(pair<A, B> p);
 
string to_string(const string& s) {
  return '"' + s + '"';
}
 
string to_string(const char* s) {
  return to_string((string) s);
}
 
string to_string(bool b) {
  return (b ? "true" : "false");
}
 
string to_string(vector<bool> v) {
  bool first = true;
  string res = "{";
  for (int i = 0; i < static_cast<int>(v.size()); i++) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(v[i]);
  }
  res += "}";
  return res;
}
 
template <size_t N>
string to_string(bitset<N> v) {
  string res = "";
  for (size_t i = 0; i < N; i++) {
    res += static_cast<char>('0' + v[i]);
  }
  return res;
}
 
template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto &x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}
 
template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
 
void debug_out() { cerr << endl; }
 
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
 
#ifdef AJ47
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 
#endif

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> oset;
typedef tree<pair<ll,ll>,null_type,less<pair<ll,ll> >,rb_tree_tag,tree_order_statistics_node_update> ordered_multiset;
mt19937 rang(chrono::high_resolution_clock::now().time_since_epoch().count());
 
const ld PI = 3.141592653589793;
const ll INF = 9223372036854775807ll;
const ll mod = 1e9 + 7;
const int N = 2e5 + 2;
vector<ll> weight[N];

ll modinv(ll x) {
    ll ans = 1, ex = mod - 2;
    while (ex > 0) {
        if (ex & 1ll) {
            ans = (ans * x) % mod;
        }
        ex >>= 1ll;
        x = (x * x) % mod;
    }
    return ans;
}


void solve() 
{
	ll n, x, y;
	cin >> n >> x >> y;
	for (int i = 0; i < n; ++i) {
		ll c, w;
		cin >> c >> w;
		weight[c].pb(w);
	}	
	ll mn = INF / 100, smn = INF / 100, idx = -1;
	for (int i = 0; i < N; ++i) {
		for (int j = 0; j < weight[i].size(); ++j) {
			if (weight[i][j] < mn) {
				mn = weight[i][j];
				idx = i;
			}
		}
	}
	for (int i = 0; i < N; ++i) if (idx != i) {
		for (int j = 0; j < weight[i].size(); ++j) {
			if (weight[i][j] < smn) {
				smn = weight[i][j];
			}
		}
	}
	debug(mn, idx, smn);
	for (int i = 0; i < N; ++i) if (weight[i].size()) sort(all(weight[i]));
	vector<ll> take;
	ll tot = 0;
	for (int i = 0; i < N; ++i) {
		if (weight[i].size()) {
			int f = 0;
			ll j = 0;
			for (j = 0; j < weight[i].size(); ++j) {
				if (i == idx) {
					if (smn + weight[i][j] > y) break;
					else f = 1;
				} else {
					if (mn + weight[i][j] > y) break;
					else f = 1;
				}
			}
			if (f) {
				for (; j < weight[i].size(); ++j) {
					if (weight[i][0] + weight[i][j] > x) break;
				}
				take.pb(j);
				tot += j;
			}
		}
	}
	ll fact[N];
	debug(take);
	fact[0] = 1, fact[1] = 1;
	for (int i = 2; i < N; ++i) fact[i] = (i * fact[i - 1]) % mod;
	ll pr = fact[tot];
	for (ll cur : take) {
		pr *= modinv(fact[cur]);
		pr %= mod;
	}
	cout << pr << endl;
}
 
int main( )
{   
    ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
    srand(chrono::high_resolution_clock::now().time_since_epoch().count());
    solve();
    return 0;
}

Measured memory_bytes: 12152