#include <bits/stdc++.h>
using namespace std;
const int MAX = 1e5 + 5;
int app[MAX];
int n;
int a, b;
int getAns(int no, int lim, int idx) {
  int ans = 0;
  for (int i = 1; i * i <= no; i++) {
    if (!(no % i)) {
      ans += !(app[i] >= lim);
      ans += !(app[no / i] >= lim) && (i != no / i);
      app[i] = idx;
      app[no / i] = idx;
    }
  }
  return ans;
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d %d", &a, &b);
    printf("%d\n", getAns(a, i - b, i));
  }
}
