#include <bits/stdc++.h>
using namespace std;
int N;
int up[100020];
int main() {
  memset(up, -1, sizeof(up));
  cin >> N;
  int a, len;
  for (int i = 0; i < N; ++i) {
    cin >> a >> len;
    int sum = 0;
    int j;
    for (j = 1; j * j < a; ++j) {
      if (a % j == 0) {
        int l = i - len;
        if (len == 0 || up[j] < l) sum++;
        up[j] = i;
        if (len == 0 || up[a / j] < l) sum++;
        up[a / j] = i;
      }
    }
    if (j * j == a) {
      int l = i - len;
      if (len == 0 || up[j] < l) sum++;
      up[j] = i;
    }
    cout << sum << endl;
  }
  return 0;
}
