#include <bits/stdc++.h>
using namespace std;
struct vec {
  long double x, y;
  bool operator==(const vec &a) const { return x == a.x && y == a.y; }
  bool operator<(const vec &a) const {
    if (a.x != x) return x < a.x;
    return y < a.y;
  }
  vec operator+(const vec &a) const { return {x + a.x, y + a.y}; }
  vec operator*(const long double &a) const { return {x * a, y * a}; }
  vec operator-(const vec &a) const { return {x - a.x, y - a.y}; }
  vec operator/(const long double &a) const { return {x / a, y / a}; }
  long double len() const { return sqrt(x * x + y * y); }
  long double dot(const vec &a) const { return x * a.x + y * a.y; }
  long double crs(const vec &a) const { return x * a.y - y * a.x; }
  vec proj(const vec &a) const {
    return (a / a.len()) * (*this).dot(a) / a.len();
  }
};
struct P {
  int x, y;
};
long long x, y, z, mod = 1000000007;
vector<int> v[411111], v1;
int i, n, m, k, a, d, b, c;
int e;
long long o[611111];
long long l[611111];
int j[1];
queue<int> q;
P u[222221];
string r[1];
map<int, int> p;
bool as(P a, P b) { return a.x < b.x; }
long long f(int n) {
  if (n > d) return 0;
  if (l[n] >= 0) return l[n];
  if (v[n].size() == 0) return l[n] = f(n + 1) + v1[n + 1] - v1[n];
  long long x = f(n + 1) + v1[n + 1] - v1[n];
  for (int h = 0; h < v[n].size(); h++) x = min(x, f(v[n][h]));
  return l[n] = x;
}
long long g(int n) {
  if (n > d) return 1;
  if (o[n] >= 0) return o[n];
  if (v[n].size() == 0) return g(n + 1);
  long long x = 0;
  if (f(n) == f(n + 1) + v1[n + 1] - v1[n]) x = g(n + 1);
  for (int h = 0; h < v[n].size(); h++)
    if (f(v[n][h]) == f(n)) x += g(v[n][h]), x %= mod;
  return o[n] = x;
}
int main() {
  memset(l, -1, sizeof(l));
  memset(o, -1, sizeof(o));
  scanf("%d", &a);
  for (int t = 1; t <= a; t++) {
    scanf("%d %d", &n, &m);
    v1.push_back(n);
    v1.push_back(m);
    d = max(d, m);
    u[t] = {m, n};
  }
  v1.push_back(0);
  sort(v1.begin(), v1.end());
  v1.resize(unique(v1.begin(), v1.end()) - v1.begin());
  for (int t = 1; t < v1.size(); t++) p[v1[t]] = t;
  d = p[d];
  for (int t = 1; t <= a; t++) {
    u[t] = {p[u[t].x], p[u[t].y]};
    v[u[t].x].push_back(u[t].y);
  }
  y = f(0);
  printf("%lld", g(0));
}
