#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

typedef long long ll;

const int MOD = 1e9 + 7; // change if needed

struct Modint {
  ll val;
  
  Modint (ll _val = 0)
    : val(_val % MOD) {}

  Modint operator+ (Modint other) const {
    return Modint(val + other.val);
  }

  void operator+= (Modint other) {
    val += other.val;
    val %= MOD;
  }

  Modint operator- () const {
    return Modint(MOD - val);
  }

  Modint operator- (Modint other) const {
    return Modint(val + MOD - other.val);
  }

  void operator-= (Modint other) {
    val += MOD - other.val;
    val %= MOD;
  }

  Modint operator* (Modint other) const {
    return Modint(val * other.val);
  }

  void operator*= (Modint other) {
    val *= other.val;
    val %= MOD;
  }

  bool operator== (Modint other) const {
    return val == other.val;
  }

  bool operator!= (Modint other) const {
    return val != other.val;
  }
};

Modint exp (Modint a, int k) {
  if (k == 0) {
    return Modint(1);
  } else if (k % 2 == 0) {
    Modint half = exp(a, k / 2);
    return half * half;
  } else {
    return a * exp(a, k - 1);
  }
}

Modint inv (Modint a) {
  return exp(a, MOD - 2);
}

ostream& operator<< (ostream& out, Modint p) {
  out << p.val;
  return out;
}

const int MAX_N = 2e5 + 5;

int xpos [MAX_N];
int speed [MAX_N];

// the initial order is by xpos, fastest first in ties
bool by_init (int p, int q) {
  if (xpos[p] != xpos[q]) {
    return xpos[p] < xpos[q];
  }
  return speed[p] > speed[q];
}

// the final order is by speed, leftmost first in ties
bool by_final (pair<int, int> p, pair<int, int> q) { // <xpos, speed>
  if (p.second != q.second) {
    return p.second < q.second;
  }
  return p.first < q.first;
}

int pos [MAX_N];
int lfend [MAX_N];
int rgend [MAX_N];

Modint dp [MAX_N];
Modint cdp [MAX_N];

Modint getsum (int l, int r) {
  if (l == 0) return cdp[r];
  return cdp[r] - cdp[l - 1];
}

int main () {
  ios::sync_with_stdio(false);
  
  int n;
  cin >> n;

  vector<pair<int, int>> vs (n);
  for (int i = 0; i < n; i++) {
    cin >> vs[i].first >> vs[i].second;
  }

  sort(vs.begin(), vs.end(), by_final);
  for (int i = 0; i < n; i++) {
    xpos[i] = vs[i].first;
    speed[i] = vs[i].second;
  }

  vector<int> perm (n);
  for (int i = 0; i < n; i++) {
    perm[i] = i;
  }
  sort(perm.begin(), perm.end(), by_init);

  /*
  for (int i = 0; i < n; i++) {
    cout << perm[i] << " ";
  }
  cout << endl;
  */

  // now we have a permutation to work with!
  for (int i = 0; i < n; i++) {
    pos[perm[i]] = i;
  }

  for (int i = n - 1; i >= 0; i--) {
    for (int j = pos[i]; j < n; j++) {
      if (rgend[j] > i) break;
      rgend[j] = i;
    }
  }

  for (int i = 0; i < n; i++) {
    lfend[i] = n + 1;
  }
  
  for (int i = 0; i < n; i++) {
    for (int j = pos[i]; j >= 0; j--) {
      if (lfend[j] < i) break;
      lfend[j] = i;
    }
  }

  for (int i = n; i >= 1; i--) {
    lfend[i] = lfend[i - 1];
    rgend[i] = rgend[i - 1];
  }
  lfend[0] = -3;
  rgend[0] = -1;
  dp[0] = Modint(1);
  cdp[0] = Modint(1);
  int curl = 0;
  for (int i = 1; i <= n; i++) {
    while (rgend[curl] + 1 < lfend[i]) {
      curl++;
    }

    dp[i] = getsum(curl, i - 1);
    cdp[i] = cdp[i - 1] + dp[i];
  }

  Modint ans (0);
  for (int i = 1; i <= n; i++) {
    if (rgend[i] == n - 1) {
      ans += dp[i];
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 12760