#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <vector>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
typedef pair<double, long long> pdl;

const long double pi = 3.141592653589793;

#define debug(x) cerr << #x << " = " << (x) << endl;
#define rep(i, n) for(int i = 0;i < n;i++)
#define pb push_back
#define mp make_pair
#define mod 1000000007
int N;
int uf[1<<20];
int height[1<<20];

void initialize() {
	rep(i, N) uf[i] = i, height[i] = 1;
}

int root(int i) {
	while (i != uf[i]) {
		i = uf[i];
	}
	return i;
}

bool same_component(int i, int j) {
	if(root(i) == root(j)) return true;
	return false;
}

void add_component(int i, int j) {
	if(same_component(i, j)) return;
	int ri = root(i);
	int rj = root(j);
	if(height[ri] == height[rj]) {
		uf[ri] = rj;
		height[rj]++;
	} else {
		(height[ri] < height[rj]) ? uf[ri] = rj : uf[rj] = ri;
	}
}

ll X, Y;
vector<pll> A(1<<20);
int make_component(int s) {
	int e = s+1;
	while (e < N and A[e].first == A[s].first) {
		if(A[e].second+A[s].second <= X) {
			add_component(s, e);
		}
		e++;
	}
	return e;
}

bool comparator(pll& u, pll& v) {
	return u.second < v.second;
}

vector<int> g[1<<20];
ll fact[1<<20];

ll power(ll x, ll n) {
	if(n == 0) return 1;
	ll y = power(x, n/2);
	if(n%2 == 0) {
		return (y*y) % mod;
	}
    return ((y*y)%mod * x) % mod;
}

ll answer = 1;
void update_answer(int s) {
	unordered_map<int, int> ma;
	for(auto &x : g[s]) {
		ma[x]++;
	}

	ll a = fact[g[s].size()];
	ll b = 1;
	for(auto it = ma.begin();it != ma.end();it++) {
		b = (b*fact[it->second]) % mod;
	}

	answer = (answer*((a*power(b, mod-2))%mod))%mod;
}

int main() {
  	//freopen("input.in","r",stdin);
  	//freopen("output.out","w",stdout);
	cin>>N>>X>>Y;
	rep(i, N) cin>>A[i].first>>A[i].second;
	sort(A.begin(), A.begin() + N);
	//rep(i, N) cout<<A[i].first<<" "<<A[i].second<<endl;
	initialize();
	int start = 0;
	while (start < N) {
		start = make_component(start);
	}

	ll minval = A[0].second;
	ll minindex = 0;
	rep(i, N) if(A[i].second < minval) {
		minval = A[i].second;
		minindex = i;
	}

	for(int i = 0;i < N;i++) {
		if(i != minindex and A[minindex].first != A[i].first and
			A[minindex].second + A[i].second <= Y) {
			add_component(minindex, i);
		}
	}

	if(N >= 2) {
		int sminindex = -1;
		for(int i = 0;i < N;i++) {
			if(A[i].first != A[minindex].first) {
				if(sminindex == -1)
					sminindex = i;
				else if(A[i].second < A[sminindex].second)
						sminindex = i;
			}
		}

		minindex = sminindex;
		if(minindex != -1)
		for(int i = 0;i < N;i++) {
			if(i != minindex and A[minindex].first != A[i].first and
				A[minindex].second + A[i].second <= Y) {
				add_component(minindex, i);
			}
		}
	}

	// rep(i, N) cout<<A[i].first<<" "; cout<<endl;
	rep(i, N) g[root(i)].pb(A[i].first);

	/*
	rep(i, N) {
		cout<<i<<": ";
		for(auto &val: g[i]) cout<<val<<" ";
		cout<<endl;
	}*/

	fact[0] = fact[1] = 1;
	for(int i = 2;i <= N;i++) fact[i] = (i*(fact[i-1])) % mod;

	rep(i, N) {
		update_answer(i);
	}

	cout<<answer<<endl;

	return 0;
}


Measured memory_bytes: 54136