#include <bits/stdc++.h>
using namespace std;
int n, i, x, y, mark[100005] = {0}, ans = 0, j;
vector<int> v;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cin >> n;
  for (i = 1; i <= n; i++) {
    cin >> x >> y;
    for (j = 1; j * j <= x; j++) {
      if (x % j == 0) {
        v.push_back(j);
        if (x / j != j) {
          v.push_back(x / j);
        }
      }
    }
    for (j = 0; j < v.size(); j++) {
      if (mark[v[j]] >= (i - y) && mark[v[j]] != 0) {
        ans += 0;
      } else
        ans++;
      mark[v[j]] = i;
    }
    v.clear();
    cout << ans << "\n";
    ans = 0;
  }
  return 0;
}
