#include<bits/stdc++.h>
#define mod 1000000007
using namespace std;
int n, x, y, mn[200007], a, b, tot, res = 1, ires = 1, inv[200007];
vector<int>num[200007];
int read()
{
	int num = 0;
	char c = getchar();
	while (c < '0' || c>'9')c = getchar();
	while (c >= '0' && c <= '9')num = num * 10 + c - '0', c = getchar();
	return num;
}
int main()
{
	n = read();
	x = read();
	y = read();
	inv[0] = inv[1] = 1;
	for (int i = 2; i <= n; i++)
		inv[i] = 1LL * (mod - mod / i) * inv[mod % i] % mod;
	memset(mn, 0x3f, sizeof mn);
	for (int i = 1; i <= n; i++)
	{
		int a = read(), b = read();
		num[a].push_back(b);
		mn[a] = min(mn[a], b);
	}
	for (int i = 1; i <= n; i++)
		if (mn[i] < mn[a])
			a = i;
	for (int i = 1; i <= n; i++)
		if (mn[i] < mn[b] && i != a)
			b = i;
	if (!b || mn[a] + mn[b] > y)
	{
		cout << 1 << endl;
		return 0;
	}
	for (int i = 1; i <= n; i++)
		if (!num[i].empty() && mn[i] + mn[a] <= y)
		{
			int cnt = 0;
			for (int j = num[i].size() - 1; j >= 0; j--)
				if (i == a)
					cnt += (num[i][j] + mn[b] <= y || num[i][j] + mn[i] <= x);
				else cnt += (num[i][j] + mn[a] <= y || num[i][j] + mn[i] <= x);
			tot += cnt;
			for (int j = 1; j <= cnt; j++)
				ires = 1LL * ires * inv[j] % mod;
		}
	for (int i = 1; i <= tot; i++)
		res = 1LL * res * i % mod;
	cout << 1LL * res * ires % mod << endl;
	return 0;
}