#include <bits/stdc++.h>
const int maxn = 100000 + 5;
int used[maxn];
int main(void) {
  int n;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    int x, y;
    scanf("%d%d", &x, &y);
    int res = 0;
    for (int j = 1; j * j <= x; j++) {
      if (x % j == 0) {
        if (used[j] < i - y) {
          res++;
        }
        used[j] = i;
        if (j * j == x) {
          continue;
        }
        if (used[x / j] < i - y) {
          res++;
        }
        used[x / j] = i;
      }
    }
    printf("%d\n", res);
  }
  return 0;
}
