#include <bits/stdc++.h>
using namespace std;
int npr;
int a[100000], f[100000], ff[100000 + 1];
int ind;
int cur;
int ans;
inline void check(int p) {
  if (ff[p] < ind) ++ans;
  ff[p] = cur;
}
inline void factor(int n) {
  for (int i = 1; i * i <= n; ++i)
    if (n % i == 0) {
      check(i);
      if (i * i != n) check(n / i);
    }
}
int n;
int main() {
  for (int i = 0; i <= 100000; ++i) ff[i] = -1;
  scanf("%d", &n);
  for (int i = 0; i < n; ++i) {
    int x, y;
    scanf("%d%d", &x, &y);
    cur = i;
    ans = 0;
    ind = i - y;
    factor(x);
    printf("%d\n", ans);
  }
  return 0;
}
