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