#include <bits/stdc++.h>
using namespace std;
map<long long, long long> M[400004];
vector<long long> Z[400004];
map<long long, long long> MA;
map<long long, long long> AM;
long long MAer;
bool cmp(long long& a, long long& b) { return a > b; }
long long xa[200002], xb[200002];
signed main() {
  long long n, a, b;
  cin >> n;
  long long maxx = 0, maxi = 0;
  for (long long i = 1; i <= n; i++) {
    cin >> a >> b;
    MA[a] = 0, MA[b] = 0;
    maxx = max(maxx, a);
    if (a == maxx) {
      maxi = max(maxi, b);
    }
    xa[i] = a, xb[i] = b;
  }
  for (auto& it : MA) {
    it.second = ++MAer;
    AM[it.second] = it.first;
  }
  for (long long i = MA[maxi] + 1; i <= MA[maxx]; i++) {
    M[i][0] = 1;
  }
  for (long long i = 1; i <= n; i++) {
    Z[MA[xa[i]]].push_back(MA[xb[i]]);
  }
  for (long long i = MA[maxx]; i > 0; i--) {
    while (M[i].size() > 1) {
      M[i].erase(++M[i].begin(), M[i].end());
    }
    for (auto& a : Z[i]) {
      for (auto& b : M[i]) {
        M[a][b.first] += b.second;
        M[a][b.first] %= 1000000007;
      }
    }
    for (auto& a : M[i]) {
      M[i - 1][AM[i] - AM[i - 1] + a.first] += a.second;
      M[i - 1][AM[i] - AM[i - 1] + a.first] %= 1000000007;
    }
  }
  cout << M[1].begin()->second << '\n';
  return 0;
}
