#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL
#include "debug.h"
#else
#define dbg(...) 47
#endif
constexpr int B = 400;
constexpr int mod = 1e9 + 7;
void add(int &a, int b) {
a += b;
if (a >= mod) {
a -= mod;
}
}
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
int n;
cin >> n;
vector<int> d(n), c(n);
for (int i = 0; i < n; i++) {
cin >> d[i] >> c[i];
}
vector<int> dp(n);
vector<vector<int>> s(B, vector<int>(B));
dp[0] = 1;
for (int i = 0; i < n; i++) {
for (int j = 1; j < B; j++) {
add(dp[i], s[j][i % j]);
}
if (d[i] >= B) {
for (int j = 1; j <= c[i] && i + j * d[i] < n; j++) {
add(dp[i + j * d[i]], dp[i]);
}
} else {
add(s[d[i]][i % d[i]], dp[i]);
}
}
int ans = 0;
for (int i = 0; i < n; i++) {
add(ans, dp[i]);
}
cout << ans << '\n';
return 0;
}