#include <bits/stdc++.h>
using namespace std;
const long long int mod = 1000000007;
const long long int N = 1e5 + 5;
vector<long long int> facs[N];
long long int last[N];
void process() {
  for (long long int i = 1; i < N; i++) {
    for (long long int j = i; j < N; j += i) {
      facs[j].push_back(i);
    }
  }
}
int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  process();
  long long int n;
  cin >> n;
  for (long long int i = 1; i <= n; i++) {
    long long int x, y;
    cin >> x >> y;
    long long int ans = 0;
    for (auto to : facs[x]) {
      if (last[to] < i - y) {
        ans++;
      }
      last[to] = i;
    }
    cout << ans << '\n';
  }
}
