#include <bits/stdc++.h>
using namespace std;
long long q1 = 1000000007, q2 = 100003;
long long p1 = 1299827, p2 = 41;
bool v[100009];
long long sp[100009];
void sieve() {
  for (long long i = 2; i < 100009; i += 2) sp[i] = 2;
  for (long long i = 3; i < 100009; i += 2) {
    if (!v[i]) {
      sp[i] = i;
      for (long long j = i; (j * i) < 100009; j += 2) {
        if (!v[j * i]) v[j * i] = true, sp[j * i] = i;
      }
    }
  }
}
set<long long> factorize(long long k) {
  set<long long> ans;
  while (k > 1) {
    ans.insert(sp[k]);
    k /= sp[k];
  }
  return ans;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long n;
  cin >> n;
  vector<long long> used(100009, -1);
  for (int i = 0; i < n; i++) {
    long long x, y;
    cin >> x >> y;
    long long ans = 0;
    for (long long j = 1; j * j <= x; j++) {
      if (x % j == 0) {
        if (used[j] == -1 || i - used[j] > y) {
          ans++;
        }
        used[j] = i;
        if (x / j != j && used[x / j] == -1 || i - used[x / j] > y) {
          ans++;
        }
        used[x / j] = i;
      }
    }
    if (used[x] == -1 || i - used[x] > y) {
      ans++;
    }
    used[x] = i;
    cout << ans << endl;
  }
  return 0;
}
