#include <bits/stdc++.h>
using namespace std;
void Weapons19() {
  cin.sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
}
vector<vector<long long int>> d;
void sieve() {
  for (long long int i = 1; i < 100005; i++) {
    for (long long int j = i; j < 100005; j += i) {
      d[j].push_back(i);
    }
  }
}
int32_t main() {
  Weapons19();
  d.resize(100005);
  long long int n;
  cin >> n;
  vector<long long int> v(100005, -1);
  sieve();
  for (long long int i = 0; i < n; i++) {
    long long int x, y;
    cin >> x >> y;
    long long int c = 0;
    for (auto a : d[x]) {
      if (v[a] < i - y) c++;
    }
    for (auto a : d[x]) v[a] = i;
    cout << c << "\n";
  }
}
