#include <bits/stdc++.h>
using namespace std;
template <class Ty, class Tx>
Ty cast(const Tx &x) {
  Ty y;
  stringstream ss("");
  ss << x;
  ss.seekg(0);
  ss >> y;
  return y;
}
int last[100005];
int main() {
  int n, i, j, x, y, z;
  for ((i) = 0; (i) < (100005); (i)++) last[i] = -1;
  cin >> n;
  for ((i) = 0; (i) < (n); (i)++) {
    cin >> x >> y;
    z = 0;
    for (j = 1; j * j <= x; j++)
      if (x % j == 0) {
        if (last[j] < 0 || i - last[j] > y) z++;
        last[j] = i;
        if (j * j != x)
          if (last[x / j] < 0 || i - last[x / j] > y) z++;
        last[x / j] = i;
      }
    cout << z << endl;
  }
  return 0;
}
