#include <bits/stdc++.h>
using namespace std;
long long const mod = 1e9 + 7;
int const MAX_N = 200010;
int const INF = INT_MAX;
vector<vector<pair<int, int>>> G(MAX_N);
vector<int> dist(MAX_N, INF);
void dijkstra(int s) {
  priority_queue<pair<int, int>, vector<pair<int, int>>,
                 greater<pair<int, int>>>
      que;
  dist[s] = 0;
  que.push(pair<int, int>(0, s));
  while (!que.empty()) {
    pair<int, int> p = que.top();
    que.pop();
    int v = p.second;
    if (dist[v] < p.first) continue;
    for (int i = 0; i < G[v].size(); ++i) {
      pair<int, int> e = G[v][i];
      if (dist[e.first] > dist[v] + e.second) {
        dist[e.first] = dist[v] + e.second;
        que.push(pair<int, int>(dist[e.first], e.first));
      }
    }
  }
}
int main() {
  int n;
  cin >> n;
  vector<pair<int, int>> a(n);
  map<int, int> mp;
  for (int i = 0; i < n; ++i) cin >> a[i].second >> a[i].first;
  a.push_back(pair<int, int>(0, 0));
  sort(a.begin(), a.end());
  for (int i = 0; i < n; ++i) {
    if (a[i].second > a[i + 1].first)
      G[i].push_back(pair<int, int>(i + 1, a[i + 1].first - a[i].first));
    if (mp.find(a[i + 1].first) == mp.end()) mp[a[i + 1].first] = i + 1;
  }
  for (int i = 0; i < n; ++i) {
    auto it = mp.lower_bound(a[i].second);
    if (it != mp.end())
      G[i].push_back(pair<int, int>(it->second, it->first - a[i].second));
  }
  dijkstra(0);
  vector<long long> dp(n + 1, 0);
  vector<bool> used(n + 1, false);
  priority_queue<pair<int, int>, vector<pair<int, int>>,
                 greater<pair<int, int>>>
      que;
  que.push(pair<int, int>(0, 0));
  used[0] = true;
  dp[0] = 1;
  while (!que.empty()) {
    pair<int, int> p = que.top();
    que.pop();
    int v = p.second;
    if (dist[v] < p.first) continue;
    for (int i = 0; i < G[v].size(); ++i) {
      pair<int, int> e = G[v][i];
      if (dist[e.first] == dist[v] + e.second) {
        (dp[e.first] += dp[v]) %= mod;
        if (!used[e.first]) {
          que.push(pair<int, int>(dist[e.first], e.first));
          used[e.first] = true;
        }
      }
    }
  }
  int in_max = 0, cost = INF;
  long long ans = 0;
  for (int i = 0; i < n + 1; ++i) in_max = max(in_max, a[i].first);
  for (int i = 0; i < n + 1; ++i)
    if (a[i].second > in_max) cost = min(cost, dist[i]);
  for (int i = 0; i < n + 1; ++i)
    if (a[i].second > in_max && dist[i] == cost) (ans += dp[i]) %= mod;
  cout << ans << endl;
  return 0;
}
