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

#include<cstdio>

#include<cstdlib>

#include<cstring>

#include<cmath>

#include<algorithm>

#include<vector>

#define MAX 200200

#define MOD 1000000007

using namespace std;

#define ll long long

inline int read()

{

	int x=0;bool t=false;char ch=getchar();

	while((ch<'0'||ch>'9')&&ch!='-')ch=getchar();

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

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

	return t?-x:x;

}

int n,X,Y,ans;

struct Ball{int c,w;}B[MAX];

bool operator<(Ball a,Ball b){if(a.c!=b.c)return a.c<b.c;return a.w<b.w;}

int jc[MAX],jv[MAX],inv[MAX];

int pmn[MAX],smn[MAX],sz[MAX],W[MAX],p[MAX];

bool cmp(int i,int j){return W[i]<W[j];}

int main()

{

	n=read();X=read();Y=read();

	for(int i=1;i<=n;++i)B[i].c=read(),B[i].w=read();

	jc[0]=jv[0]=inv[0]=inv[1]=1;

	for(int i=2;i<=n;++i)inv[i]=1ll*inv[MOD%i]*(MOD-MOD/i)%MOD;

	for(int i=1;i<=n;++i)jc[i]=1ll*jc[i-1]*i%MOD,jv[i]=1ll*jv[i-1]*inv[i]%MOD;

	sort(&B[1],&B[n+1]);

	memset(pmn,63,sizeof(pmn));

	memset(smn,63,sizeof(smn));

	memset(W,63,sizeof(W));

	for(int i=1,j;i<=n;i=j+1)

	{

		j=i;while(j<n&&B[i].c==B[j+1].c)++j;

		pmn[B[i].c]=smn[B[i].c]=B[i].w;

	}

	for(int i=1;i<=n;++i)pmn[i]=min(pmn[i],pmn[i-1]);

	for(int i=n;i>=1;--i)smn[i]=min(smn[i],smn[i+1]);

	for(int i=1,j;i<=n;i=j+1)

	{

		j=i;while(j<n&&B[i].c==B[j+1].c)++j;

		int d=min(pmn[B[i].c-1],smn[B[i].c+1]);

		int cnt=1;

		for(int k=i+1;k<=j;++k)

			if(B[i].w+B[k].w<=X||B[k].w+d<=Y)++cnt;

			else break;

		sz[B[i].c]=cnt;W[B[i].c]=B[i].w;

	}

	for(int i=1;i<=n;++i)p[i]=i;

	sort(&p[1],&p[n+1],cmp);

	for(int i=1;i<=n;++i)

		if(i==1||W[p[i]]+W[p[1]]<=Y)

			ans+=sz[p[i]];

	ans=jc[ans];

	for(int i=1;i<=n;++i)

		if(i==1||W[p[i]]+W[p[1]]<=Y)

			ans=1ll*ans*jv[sz[p[i]]]%MOD;

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

	return 0;

}


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



#define MAXN 200005

#define INF 0x3f3f3f3f



typedef long long lint;



using namespace std;



const int mod = 1e9 + 7;

int n, x, y;

int c[MAXN], w[MAXN], mini[MAXN];

int sum[MAXN], amount;

int first, second, firstc;

lint fac[MAXN], inf[MAXN];



int read() {

    char c = getchar();

    int x = 0;

    while (!isdigit(c))

        c = getchar();

    while (isdigit(c)) {

        x = (x << 3) + (x << 1) + c - '0';

        c = getchar();

    }

    return x;

}



lint power(lint a, int b) {

    lint res = 1;

    while (b) {

        if (b & 1)

            res = res * a % mod;

        a = a * a % mod;

        b >>= 1;

    }

    return res;

}



void init() {

    fac[0] = inf[0] = 1;

    for (int i = 1; i <= n; ++i)

        fac[i] = fac[i - 1] * i % mod;

    inf[n] = power(fac[n], mod - 2);

    for (int i = n - 1; i >= 1; --i)

        inf[i] = inf[i + 1] * (i + 1) % mod;

}



int main() {

//    freopen("15.txt", "r",stdin);

    n = read();

    x = read();

    y = read();

    init();

    memset(mini, 0x3f, sizeof(mini));

    for (int i = 1; i <= n; ++i) {

        c[i] = read();

        w[i] = read();

        mini[c[i]] = min(mini[c[i]], w[i]);

    }

    for (int i = 1; i <= n; ++i)

        if (mini[c[i]] + w[i] <= x)

            w[i] = mini[c[i]];

    first = second = INF;

    for (int i = 1; i <= n; ++i)

        if (mini[i] < first) {

            second = first;

            first = mini[i];

            firstc = i;

        }

        else if (mini[i] < second)

            second = mini[i];

//    printf("%d %d\n", first, second);

    if (first + second <= y)

        for (int i = 1; i <= n; ++i)

            if (c[i] == firstc && w[i] != first && w[i] + second <= y)

                w[i] = first;

    for (int i = 1; i <= n; ++i)

        if (c[i] == firstc && w[i] == first) {

//            cout << "first: " << i << endl;

            ++sum[c[i]];

            ++amount;

        }

        else if (c[i] != firstc && w[i] + first <= y) {

//            cout << "second: " << i << endl;

            ++sum[c[i]];

            ++amount;

        }

    lint res = fac[amount];

    for (int i = 1; i <= n; ++i)

        res = res * inf[sum[i]] % mod;

    printf("%lld\n", res);

}