#include <bits/stdc++.h>
int gao[100001];
int main() {
  int T;
  scanf("%d", &T);
  for (int zt = 1; zt <= T; zt++) {
    int x, y;
    scanf("%d%d", &x, &y);
    int ans = 0;
    for (int i = 1; i * i <= x; i++)
      if (x % i == 0) {
        if (gao[i] < zt - y) {
          ans++;
        }
        gao[i] = zt;
        if (i * i != x && gao[x / i] < zt - y) {
          ans++;
        }
        gao[x / i] = zt;
      }
    printf("%d\n", ans);
  }
}
