#include <bits/stdc++.h>
using namespace std;
const int INF = 100000000;
vector<int> divs(int n) {
  vector<int> div(0);
  int i;
  for (i = 1; i * i < n; ++i)
    if (n % i == 0) {
      div.push_back(i);
      div.push_back(n / i);
    }
  if (i * i == n) div.push_back(i);
  return div;
}
int main() {
  int n;
  cin >> n;
  map<int, int> ldiv;
  for (int i = 1; i <= n; ++i) {
    int x, y;
    cin >> x >> y;
    vector<int> div = divs(x);
    int count = 0;
    for (int j = 0; j < div.size(); j++) {
      if (ldiv[div[j]] < i - y) ++count;
      ldiv[div[j]] = i;
    }
    cout << count << endl;
  }
  return 0;
}
