#include <bits/stdc++.h>
using namespace std;
int main() {
  int i, j;
  int n, x[100000], y[100000];
  int use[100001];
  vector<int> d[100000];
  cin >> n;
  for (i = 0; i < n; i++) cin >> x[i] >> y[i];
  for (i = 0; i < n; i++) {
    int sq = (int)sqrt(x[i]);
    for (j = 1; j <= sq; j++) {
      if (!(x[i] % j)) {
        d[i].push_back(j);
        if (j * j != x[i]) d[i].push_back(x[i] / j);
      }
    }
  }
  for (i = 0; i < 100000; i++) use[i] = -1;
  for (i = 0; i < n; i++) {
    int ans = 0;
    for (j = 0; j < (int)d[i].size(); j++) {
      if (use[d[i][j]] < i - y[i]) ans++;
      use[d[i][j]] = i;
    }
    cout << ans << endl;
  }
}
