#include <bits/stdc++.h>
int p[100010], i, j, x, y, n, a;
int main() {
  scanf("%d", &n);
  for (i = 1; a = 0, i <= n; ++i) {
    scanf("%d%d", &x, &y);
    for (j = 1; j * j < x; ++j)
      if (x % j == 0) {
        if (p[j] < i - y) ++a;
        p[j] = i;
        if (p[x / j] < i - y) ++a;
        p[x / j] = i;
      }
    if (x % j == 0) {
      if (p[j] < i - y) ++a;
      p[j] = i;
      ;
    }
    printf("%d\n", a);
  }
  return 0;
}
