#include <bits/stdc++.h>
using namespace std;
int sign[100005];
int main() {
  int n;
  scanf("%d", &n);
  memset(sign, 0, sizeof(sign));
  for (int t = 1; t <= n; t++) {
    int x, y, ans = 0;
    scanf("%d%d", &x, &y);
    int tmp = (int)sqrt(1.0 * x);
    if (tmp * tmp == x) {
      if (y == 0 || sign[tmp] == 0 || t - y > sign[tmp]) {
        ans++;
      }
      sign[tmp] = t;
      tmp--;
    }
    for (int i = 1; i <= tmp; i++) {
      if (x % i == 0) {
        if (y == 0 || sign[i] == 0 || t - y > sign[i]) {
          ans++;
        }
        sign[i] = t;
        int z = x / i;
        if (y == 0 || sign[z] == 0 || t - y > sign[z]) {
          ans++;
        }
        sign[z] = t;
      }
    }
    printf("%d\n", ans);
  }
}
