#include <bits/stdc++.h>
using namespace std;
const int N = 101 * 1001;
int last[N];
int main() {
  for (int i = 0; i < (N); ++i) last[i] = -N;
  int n;
  scanf("%d", &n);
  for (int j = 0; j < (n); ++j) {
    int x, y;
    scanf("%d %d", &x, &y);
    int i = 1;
    int res = 0;
    while (i * i < x) {
      if (x % i == 0) {
        if (last[i] < j - y) res++;
        last[i] = j;
        int a = x / i;
        if (last[a] < j - y) res++;
        last[a] = j;
      }
      i++;
    }
    if (i * i == x) {
      if (last[i] < j - y) res++;
      last[i] = j;
    }
    printf("%d\n", res);
  }
  return 0;
}
