#include <bits/stdc++.h>
const int N = 100000;
int pos[N];
int main() {
  int n, i, j, x, y, cnt;
  while (scanf("%d", &n) == 1) {
    memset(pos, 0, sizeof(pos));
    for (i = 1; i <= n; i++) {
      scanf("%d%d", &x, &y);
      for (j = 1, cnt = 0; j * j <= x; j++)
        if (x % j == 0) {
          if (pos[j] < i - y) cnt++;
          pos[j] = i;
          if (x != j * j) {
            if (pos[x / j] < i - y) cnt++;
            pos[x / j] = i;
          }
        }
      printf("%d\n", cnt);
    }
  }
  return 0;
}
