/**
* author: Vi Gia Huy
* Vi Gia Huy will win APIO
**/
#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1e9 + 7;
const int N = 555;
int n;
long long a[N], b[N];
namespace sub1 {
long long dp[N];
void sol() {
for (int i = 1; i <= n; i++) {
dp[i] = 1;
for (int j = 1; j < i; j++) {
if (a[i] > a[j]) {
dp[i] = (dp[i] + dp[j]) % MOD;
}
}
}
long long ans = 0;
for (int i = 1; i <= n; i++) ans = (ans + dp[i]) % MOD;
cout << ans;
return;
}
}
namespace sub2 {
const int M = 1e6 + 5;
int m;
long long bit[M];
vector<long long> comp;
void update(int idx, long long val) {
for (; idx <= m; idx += idx & -idx) {
bit[idx] = (bit[idx] + val) % MOD;
}
}
long long query(int idx) {
long long res = 0;
for (; idx > 0; idx -= idx & -idx) {
res = (res + bit[idx]) % MOD;
}
return res;
}
int getrank(long long x) {
return lower_bound(comp.begin(), comp.end(), x) - comp.begin() + 1;
}
void sol() {
for (int i = 1; i <= n; i++) {
for (long long x = a[i]; x <= b[i]; x++) {
comp.push_back(x);
}
}
sort(comp.begin(), comp.end());
comp.erase(unique(comp.begin(), comp.end()), comp.end());
m = comp.size();
for (int i = 1; i <= n; i++) {
int l = getrank(a[i]);
int r = getrank(b[i]);
for (int j = r; j >= l; j--) {
long long tmp = (query(j - 1) + 1) % MOD;
update(j, tmp);
}
}
cout << query(m);
return;
}
}
namespace sub3 {
void sol() {
return;
}
}
namespace sub4 {
void sol() {
return;
}
}
int main() {
ios::sync_with_stdio(0); cin.tie(0);
bool checksub1 = true;
long long total = 0;
cin >> n;
for (int i = 1; i <= n; i++) {
cin >> a[i] >> b[i];
total += b[i] - a[i];
if (a[i] != b[i]) checksub1 = false;
}
if (n <= 500 && checksub1) sub1::sol();
else if (n <= 500 && total <= 1e6) sub2::sol();
else if (n <= 100) sub3::sol();
else sub4::sol();
return 0;
}