#include <bits/stdc++.h>
using namespace std;
int last_appearance[111111];
int main() {
  int n;
  while (cin >> n) {
    vector<int> x(n);
    vector<int> y(n);
    for (size_t i = 0; i < n; i++) {
      cin >> x[i] >> y[i];
    }
    memset(last_appearance, -1, sizeof(last_appearance));
    for (int i = 0; i < n; i++) {
      int cnt = 0;
      for (int j = 1; j * j <= x[i]; j++) {
        if (x[i] % j == 0) {
          int p = j;
          int q = x[i] / j;
          if (last_appearance[p] < i - y[i]) {
            cnt++;
          }
          last_appearance[p] = i;
          if (last_appearance[q] < i - y[i]) {
            cnt++;
          }
          last_appearance[q] = i;
        }
      }
      cout << cnt << endl;
    }
  }
  return 0;
}
