#include <bits/stdc++.h>
using namespace std;
const long long N = 1e5 + 5;
long long last[N];
vector<long long> fact[N];
void generate() {
  for (long long i = 1; i < N; i++) {
    for (long long j = 1; i * j < N; j++) {
      fact[i * j].push_back(i);
    }
  }
}
int32_t main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  long long n;
  cin >> n;
  generate();
  for (long long i = 1; i <= n; i++) {
    long long ans = 0;
    long long x, y;
    cin >> x >> y;
    for (auto it : fact[x]) {
      if (i - last[it] > y) ans++;
    }
    cout << ans << "\n";
    for (auto it : fact[x]) last[it] = i;
  }
  return 0;
}
