#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  scanf("%d", &n);
  int a, b;
  vector<int> vect(100009);
  for (int i = 1; i <= n; ++i) {
    scanf("%d %d", &a, &b);
    int sol = 0;
    int sq = sqrt(a);
    for (int j = 1; j <= sq; j++) {
      if (a % j == 0) {
        if (vect[j] < i - b) sol++;
        if (vect[a / j] < i - b && (a / j) != j) sol++;
        vect[j] = i;
        vect[a / j] = i;
      }
    }
    printf("%d\n", sol);
  }
  return 0;
}
