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