#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
const long long maxn = 2e5 + 10;
const pair<long long, long long> inf = make_pair(1e10, 0);
long long N;
long long a, b;
long long off = 1;
long long maxin = 0;
long long minout = 1e10;
pair<long long, long long> curr;
vector<pair<long long, long long> > v;
long long add(long long x, long long y) {
  if (x > mod) x = x % mod;
  if (y > mod) y = y % mod;
  if (x + y > mod) return x + y - mod;
  return x + y;
}
struct Tournament {
  pair<long long, long long> t[4 * maxn];
  Tournament(){};
  void create(int x) {
    for (int i = 1; i < 2 * x; i++) t[x] = inf;
  }
  void calc(int x) {
    if (t[x * 2].first < t[x * 2 + 1].first) {
      t[x].first = t[x * 2].first;
      t[x].second = t[x * 2].second;
    } else if (t[x * 2].first > t[x * 2 + 1].first) {
      t[x].first = t[x * 2 + 1].first;
      t[x].second = t[x * 2 + 1].second;
    } else {
      t[x].first = t[x * 2].first;
      t[x].second = add(t[x * 2].second, t[x * 2 + 1].second);
    }
    return;
  }
  void ubaci(int x) {
    while (x != 0) {
      calc(x);
      x /= 2;
    }
    return;
  }
  void query(int x, int myl, int myr, int l, int r) {
    if (myl > r || myr < l) return;
    if (myl <= l && myr >= r) {
      if (curr.first > t[x].first)
        curr = t[x];
      else if (curr.first == t[x].first)
        curr.second = add(curr.second, t[x].second);
      return;
    }
    int mid = (l + r) / 2;
    query(x * 2, myl, myr, l, mid);
    query(x * 2 + 1, myl, myr, mid + 1, r);
    return;
  }
} T;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> N;
  for (int i = 0; i < N; i++) {
    cin >> a >> b;
    maxin = max(maxin, b);
    minout = min(minout, a);
    pair<long long, long long> p = make_pair(b, a);
    v.push_back(p);
  }
  sort(v.begin(), v.end());
  while (off < N) off *= 2;
  T.create(off);
  for (int i = N - 1; i >= 0; i--) {
    if (v[i].second > maxin) {
      T.t[off + i] = make_pair(v[i].first, 1);
      T.ubaci((off + i) / 2);
    } else {
      pair<long long, long long> p_min = make_pair(v[i].second, 0);
      pair<long long, long long> p_max;
      long long low = lower_bound(v.begin(), v.end(), p_min) - v.begin();
      p_max = make_pair(v[low].second - 1, 1e10);
      long long high = upper_bound(v.begin(), v.end(), p_max) - v.begin();
      high--;
      curr = inf;
      T.query(1, low + 1, high + 1, 1, off);
      T.t[off + i] =
          make_pair(curr.first - v[i].second + v[i].first, curr.second);
      T.ubaci((off + i) / 2);
    }
  }
  pair<long long, long long> p = make_pair(minout, 0);
  long long poz = lower_bound(v.begin(), v.end(), p) - v.begin();
  curr = inf;
  T.query(1, 1, poz, 1, off);
  cout << curr.second;
}
