#include <bits/stdc++.h>
using namespace std;
const int INF = (int)1e9 + 10;
const int MOD = (int)1e9 + 7;
void factorize(int);
set<int> factors;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n;
  cin >> n;
  vector<int> last(100001);
  for (int i = 1; i <= n; i++) {
    int tmp, diff, ans = 0;
    cin >> tmp >> diff;
    factorize(tmp);
    for (auto factor : factors)
      ans += (last[factor] < i - diff), last[factor] = i;
    cout << ans << "\n";
  }
  return 0;
}
void factorize(int x) {
  factors.clear();
  factors.insert(1);
  vector<int> nw;
  int cpyX = x;
  for (int i = 2; x != 1 && i * i <= cpyX; i++) {
    if (x % i == 0) {
      for (auto factor : factors) nw.push_back(factor * i);
      for (auto btts : nw) factors.insert(btts);
      x /= i--;
      nw.clear();
    }
  }
  if (x != 1) {
    for (auto factor : factors) nw.push_back(factor * x);
    for (auto btts : nw) factors.insert(btts);
  }
  return;
}
