#include <bits/stdc++.h>
#include <bits/extc++.h>
using namespace __gnu_pbds;
using namespace std;
// #pragma GCC optimize("Ofast")
// #pragma GCC optimize ("unroll-loops")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define ff first
#define sc second
#define pb push_back
#define ll long long
#define pll pair<ll, ll>
#define pii pair<int, int>
#define ull unsigned long long
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
mt19937_64 rngl(chrono::steady_clock::now().time_since_epoch().count());
// #define int long long
// #define int unsigned long long
// #define ordered_set(T) tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>
// #define ordered_multiset(T) tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>
const ll mod = 1e9 + 7;
// const ll mod = 998244353;
const ll inf = 1e9;
const ll biginf = 1e18;
const int maxN = 1e5 + 15;
const int sq = 300;
void solve() {
int n;
cin >> n;
int d[n + 1], x[n + 1];
for (int i = 1; i <= n; i++)
cin >> d[i] >> x[i];
ll dp[n + 1]{}, pref[n + 1][sq + 1]{}; dp[1] = 1;
for (int i = 1; i <= n; i++) {
for (int j = 1; j <= min(sq, i); j++) {
pref[i][j] += pref[i - j][j];
(dp[i] += pref[i][j]) %= mod;
}
if (d[i] == 0) continue;
if (d[i] >= sq) for (int j = 1; j <= x[i] && i + j * d[i] <= n; j++) (dp[i + j * d[i]] += dp[i]) %= mod;
else {
if (i + d[i] <= n) (pref[i + d[i]][d[i]] += dp[i]) %= mod;
int mx = min(x[i], (n - i) / d[i]) + 1;
if (i + mx * d[i] <= n) (pref[i + mx * d[i]][d[i]] += mod - dp[i]) %= mod;
}
}
ll ans = 0;
for (int i = 1; i <= n; i++) (ans += dp[i]) %= mod;
cout << ans;
}
int32_t main() {
// #ifndef ONLINE_JUDGE
// freopen("input.txt", "r", stdin);
// freopen("output.txt", "w", stdout);
// #endif
// ios_base::sync_with_stdio(false);
// cin.tie(nullptr); cout.tie(nullptr);
int t = 1;
// cin >> t;
while (t--) {
solve();
// cout << '\n';
}
return 0;
}