#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:256000000")
using namespace std;
int main() {
  int n, a, b, t, g;
  cin >> n;
  map<int, int> r;
  for (int x = 1; x <= n; x++) {
    cin >> a >> b;
    t = sqrt((double)a);
    g = 0;
    for (int y = 1; y <= t + 1; y++) {
      if (a % y == 0) {
        if (r[y] < x - b) {
          g++;
        }
        r[y] = x;
        if (r[a / y] < x - b) {
          g++;
        }
        r[a / y] = x;
      }
    }
    cout << g << endl;
  }
  return 0;
}
