#include <bits/stdc++.h>
using namespace std;
bool divc[100001][318];
int sum[100001][318];
int n;
int x[100001], y[100001];
set<pair<int, int> > comp;
int main() {
  memset(divc, 0, sizeof(divc));
  memset(sum, 0, sizeof(sum));
  comp.clear();
  cin >> n;
  for (int i = 0; i < (int)(n); i++) cin >> x[i + 1] >> y[i + 1];
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j < 318; j++) {
      if (x[i] % j == 0) {
        divc[i][j] = 1;
        sum[i][j]++;
        int c = x[i] / j;
        if (c >= 318) {
          comp.insert(make_pair(c, i));
        }
      }
      if (i + 1 < 100001) {
        sum[i + 1][j] = sum[i][j];
      }
    }
  }
  for (int i = 1; i <= n; i++) {
    int ans = 0;
    for (int j = 1; j < 318; j++) {
      if (!divc[i][j]) continue;
      if (!(sum[i - 1][j] - sum[i - y[i] - 1][j])) {
        ans++;
      }
      int c = x[i] / j;
      if (c >= 318) {
        set<pair<int, int> >::iterator it = comp.lower_bound(make_pair(c, i));
        if (it != comp.begin()) {
          it--;
          if (it->first != c || it->second < i - y[i]) {
            ans++;
          }
        } else {
          ans++;
        }
      }
    }
    cout << ans << endl;
  }
  return 0;
}
