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