#include <bits/stdc++.h>
using namespace std;
int d[100001];
int main() {
  int n;
  scanf("%d", &n);
  memset(d, -1, sizeof d);
  for (int j = 0; j < n; j++) {
    int x, y;
    scanf("%d%d", &x, &y);
    int res = 0;
    for (int i = 1; i * i <= x; i++) {
      if (x % i == 0) {
        if (d[i] < j - y) res++;
        if (x / i != i && d[x / i] < j - y) res++;
        d[i] = d[x / i] = j;
      }
    }
    cout << res << endl;
  }
  return 0;
}
