#include <bits/stdc++.h>
using namespace std;
const int MAX = 100003;
int n, x, y, loc[MAX];
int main() {
  scanf("%d", &n);
  for (int k = 1; k <= n; k++) {
    scanf("%d %d", &x, &y);
    int kor = sqrt(x), sol = 0;
    for (int i = 2; i <= kor; i++)
      if (x % i == 0) {
        if (loc[i] < k - y) sol++;
        if (loc[x / i] < k - y and (i != kor or kor * kor != x)) sol++;
        loc[i] = loc[x / i] = k;
      }
    if (loc[x] < k - y and x != 1) sol++;
    loc[x] = k;
    printf("%d\n", sol + !y);
  }
  return 0;
}
