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