#include <bits/stdc++.h>

using namespace std;

#define sqr(x) ((x) * (x))
#define pb push_back
#define mp make_pair
#define ins insert
#define er erase
#define bg begin()
#define ed end()
#define f first
#define s second
#define fin(name) freopen(name, "r", stdin)
#define fout(name) freopen(name, "w", stdout)
#define files(name) fin(name".in"); fout(name".out")
#define enter cout << "\n"
#define space cout << " "
#define endl "\n"
#define fi(st,n) for (int i = (st); i <= (n); ++i)
#define fj(st,n) for (int j = (st); j <= (n); ++j)
#define fk(st,n) for (int k = (st); k <= (n); ++k)
#define fq(st,n) for (int q = (st); q <= (n); ++q)
#define fw(st,n) for (int w = (st); w <= (n); ++w)
#define ff(i, st, n) for (int (i) = (st); (i) <= (n); ++(i))
#define ei(st,n) for (int i = (st); i >= (n); --i)
#define ej(st,n) for (int j = (st); j >= (n); --j)
#define ek(st,n) for (int k = (st); k >= (n); --k)
#define ef(i, st, n) for (int (i) = (st); (i) >= (n); --(i))
#define ri(st,n) for (int i = (st); i < (n); ++i)
#define rj(st,n) for (int j = (st); j < (n); ++j)
#define rk(st,n) for (int k = (st); k < (n); ++k)
#define rq(st,n) for (int q = (st); q < (n); ++q)
#define rf(i, st, n) for (int (i) = (st); (i) < (n); ++(i))
#define clean(a) memset((a),0,sizeof (a))
#define sync ios_base::sync_with_stdio(0);cin.tie(0)
#define y1 dsklmlvmd

typedef long long ll;
typedef unsigned long long ull;
typedef double dbl;
typedef long double ldbl;
typedef pair<int, int> pii;
typedef vector<int> vi;

const int inf = (int)1e9;
const dbl eps = (dbl) 1e-8;
const int mod = (int) 1e9 + 7;
const int maxn = (int) 2e5 + 5;
//const dbl M_PI = (dbl)2 * (dbl)acos(0);

//cout<<fixed<<setprecision(10);
//srand(time(0));

ll A, B, mn[maxn], c[maxn], w[maxn];
pair <ll, ll> m;
vector <ll> a[maxn];
ll answer;
ll nans;
vector <ll> ans;
ll f[maxn], of[maxn];
ll n, dc;

ll step(ll a, ll b) {
    if (b == 0)
        return 1;
    if (b & 1) {
        return (a * step(a, b - 1)) % mod;
    } else {
        a = step(a, b / 2);
        return (a * a) % mod;
    }
}

int main() {
//    fin("t.in");
    sync;
    cin >> n >> A >> B;
    fi(1, n) {
        mn[i] = 2 * inf;
    }
    fi(1, n) {
        cin >> c[i] >> w[i];
        a[c[i]].pb(w[i]);
        mn[c[i]] = min(mn[c[i]], w[i]);
    }
    m = mp(0, 0);
    fi(1, n) {
        if (a[i].size() == 0)
            continue;
        sort(a[i].begin(), a[i].end());
        if (m.f == 0 || mn[i] < mn[m.f]) {
            m.s = m.f;
            m.f = i;
        } else
        if (m.s == 0 || mn[i] < mn[m.s]) {
            m.s = i;
        }
    }
    ans.clear();
    nans = 0;
    fi(1, n) {
        if (!a[i].size())
            continue;
        if (i != m.f)
            dc = mn[m.f];
        else
            dc = mn[m.s];
        if (mn[i] + dc > B) {
            continue;
        }
        ans.pb(0);
        rj(0, a[i].size()) {
            if (a[i][j] + dc <= B || a[i][j] + mn[i] <= A) {
                ++nans;
                ++ans[(int)ans.size() - 1];
            }
        }
    }
    f[0] = 1;
    fi(1, n) {
        f[i] = (f[i - 1] * (ll)i) % mod;
        of[i] = step(f[i], mod - 2);
    }
    answer = f[nans];
    ri(0, ans.size()) {
        answer = (answer * of[ans[i]]) % mod;
    }
    cout << answer << endl;
    return 0;
}

Measured memory_bytes: 18424