#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 55;
int n, x[N], y[N];
int lst[N];
vector<int> factors[N];
vector<int> f(int x) {
  vector<int> res;
  for (int i = 1; i * i <= x; ++i) {
    if (x % i == 0) {
      res.push_back(i);
      if (i * i != x) res.push_back(x / i);
    }
  }
  return res;
}
int main() {
  ios::sync_with_stdio(0), cin.tie(0);
  cin >> n;
  for (int i = 1; i <= n; ++i) cin >> x[i] >> y[i], factors[x[i]] = f(x[i]);
  for (int i = 1; i <= n; ++i) {
    int res = 0;
    if (y[i] == 0) {
      res = factors[x[i]].size();
    } else {
      for (auto s : factors[x[i]]) {
        if (s != 1 && lst[s] < i - y[i]) ++res;
      }
    }
    for (auto s : factors[x[i]]) lst[s] = i;
    cout << res << '\n';
  }
  return 0;
}
