#include <bits/stdc++.h>
using namespace std;
vector<int> divisors(int num) {
  vector<int> divs;
  int sq = (int)(sqrt(1.0 * num) + 0.001);
  for (int i = 1; i <= sq; i++) {
    if (num % i == 0) {
      divs.push_back(i);
      if (num / i != i) divs.push_back(num / i);
    }
  }
  sort((divs).begin(), (divs).end());
  return divs;
}
int last[1000005];
class Solution {
 public:
  void solve(std::istream& in, std::ostream& out) {
    int n;
    in >> n;
    for (int i = 1; i <= n; i++) {
      int x, y;
      in >> x >> y;
      vector<int> dvs = divisors(x);
      int cnt = 0;
      if (i == 1) {
        out << (int)dvs.size() << '\n';
        for (int j = 0; j <= (int)dvs.size() - 1; j++) {
          int d = dvs[j];
          last[d] = i;
        }
        continue;
      }
      for (int j = 0; j <= (int)dvs.size() - 1; j++) {
        int d = dvs[j];
        int ind = last[d];
        if (ind >= i - y && ind < i) cnt++;
      }
      for (int j = 0; j <= (int)dvs.size() - 1; j++) {
        int d = dvs[j];
        last[d] = i;
      }
      out << (int)dvs.size() - cnt << '\n';
    }
    return;
  }
};
void solve(std::istream& in, std::ostream& out) {
  out << std::setprecision(12);
  Solution solution;
  solution.solve(in, out);
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  istream& in = cin;
  ostream& out = cout;
  solve(in, out);
  return 0;
}
