#include <bits/stdc++.h>
long hash[100006] = {0};
int main() {
  long n, i, j, x, y;
  long s = 0;
  scanf("%ld", &n);
  for (i = 1; i <= n; i++) {
    scanf("%ld%ld", &x, &y);
    s = 0;
    for (j = 1; j * j <= x; j++)
      if (x % j == 0) {
        if (hash[j] < i - y) s++;
        hash[j] = i;
        if (j * j != x) {
          if (hash[x / j] < i - y) s++;
          hash[x / j] = i;
        }
      }
    printf("%ld\n", s);
  }
  return 0;
}
