#include <bits/stdc++.h>
using namespace std;
int main() {
  std::ios_base::sync_with_stdio(false);
  int n;
  cin >> n;
  vector<vector<int>> numbers(100000 + 1);
  vector<int> xs(100000 + 1), ys(100000 + 1);
  for (int i = 1; i <= n; ++i) {
    cin >> xs[i] >> ys[i];
    numbers[xs[i]].push_back(i);
  }
  vector<vector<int>> dividable(100000);
  for (int d = 1; d <= 100000; ++d) {
    for (int dd = d; dd <= 100000; dd += d) {
      for (auto shit : numbers[dd]) {
        dividable[d].push_back(shit);
      }
    }
    if (!dividable[d].empty()) sort(dividable[d].begin(), dividable[d].end());
  }
  auto find_divisable = [&](int d, int first, int last) {
    auto it = lower_bound(dividable[d].begin(), dividable[d].end(), first);
    if (it == dividable[d].end()) return false;
    if (*it < last) return true;
    return false;
  };
  for (int i = 1; i <= n; ++i) {
    int ans = 0;
    int x = xs[i], y = ys[i];
    for (int d = 1; d * d <= x; ++d) {
      if (x % d != 0) continue;
      if (!find_divisable(d, i - y, i)) ans += 1;
      int od = x / d;
      if (od > d) {
        if (!find_divisable(od, i - y, i)) ans += 1;
      }
    }
    cout << ans << "\n";
  }
  cout << endl;
}
