#include <bits/stdc++.h>
using namespace std;
vector<long long> v[100001];
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long n, x, y;
  cin >> n;
  for (long long i = 1; i <= 100000; i++) {
    for (long long j = 1; j <= sqrt(i); j++) {
      if (i % j == 0) {
        v[i].push_back(j);
        if (i / j != j) v[i].push_back(i / j);
      }
    }
  }
  long long count[100001] = {0};
  for (long long i = 1; i <= 100000; i++) sort(v[i].begin(), v[i].end());
  for (long long j = 1; j <= n; j++) {
    cin >> x >> y;
    long long k = v[x].size();
    long long ans = 0;
    for (long long i = 0; i < k; i++)
      if (count[v[x][i]] < j - y) ans++;
    for (long long i = 0; i < k; i++) count[v[x][i]] = j;
    cout << ans << endl;
  }
}
