#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vs = vector<string>;
using pll = pair<ll, ll>;
using vpl = vector<pll>;
using vl = vector<ll>;
using vvl = vector<vl>;
const ll mod = 1e9 + 7;
int main(void) {
  ll n;
  cin >> n;
  map<ll, map<ll, ll>> graph;
  ll max_in = 0;
  for (ll i = 0; i < (n); (i)++) {
    ll out, in;
    cin >> out >> in;
    max_in = max(max_in, in);
    graph[out][in]++;
  }
  map<ll, pll> dp;
  dp[0] = {1, 0};
  for (const auto& foo : graph) {
    const ll& to = foo.first;
    const map<ll, ll>& in = foo.second;
    for (const auto& bar : in) {
      const ll& from = bar.first;
      const ll& cnt = bar.second;
      auto it = dp.upper_bound(from);
      it--;
      assert(it != dp.end());
      ll extra_space = from - it->first + it->second.second;
      {
        if (0) cerr << ("extra_space") << " = " << (extra_space) << endl;
      };
      ll add = (cnt * it->second.first) % mod;
      if (!((dp).find(to) != (dp).end())) {
        auto iter = dp.lower_bound(to);
        iter--;
        dp[to] = {iter->second.first, iter->second.second + (to - iter->first)};
      }
      if (dp[to].second > extra_space)
        dp[to] = {add, extra_space};
      else if (dp[to].second == extra_space)
        dp[to].first += add;
      dp[to].first %= mod;
      {
        if (0) cerr << ("to") << " = " << (to) << endl;
      };
      {
        if (0) cerr << ("dp[to].xx") << " = " << (dp[to].first) << endl;
      };
      {
        if (0) cerr << ("dp[to].yy") << " = " << (dp[to].second) << endl;
      };
      {
        if (0)
          cerr << "------------------------------------------------------------"
                  "--"
                  "--------"
               << endl;
      };
    }
  }
  ll sum = 0;
  ll lextra = 1e11;
  for (auto it = dp.rbegin(); it != dp.rend(); it++) {
    if (it->first == max_in) {
      {
        if (0)
          cerr << "------------------------------------------------------------"
                  "--"
                  "--------"
               << endl;
      };
    }
    if (it->first <= max_in) {
      {
        if (0) cerr << ("it->xx") << " = " << (it->first) << endl;
      };
      {
        if (0) cerr << ("it->yy.xx") << " = " << (it->second.first) << endl;
      };
      {
        if (0) cerr << ("it->yy.yy") << " = " << (it->second.second) << endl;
      };
      continue;
    }
    if (it->second.second < lextra) {
      {
        if (0) cerr << ("\"changed\"") << " = " << ("changed") << endl;
      };
      lextra = it->second.second;
      sum = 0;
    }
    if (it->second.second <= lextra) {
      {
        if (0) cerr << ("it->yy.xx") << " = " << (it->second.first) << endl;
      };
      {
        if (0) cerr << ("it->yy.yy") << " = " << (it->second.second) << endl;
      };
      sum = (sum + it->second.first) % mod;
    }
  }
  cout << sum << endl;
}
