#include <bits/stdc++.h>
using namespace std;
long long ll, tt, i, p1, p2, har, j, b[311212], c[211456], d[1213456],
    a[1234567];
long long x, m, n, r, s, t, k, l, y, z;
vector<long long> p[234567], q, pp;
map<long long, long long> w, ww;
int main() {
  l = 100000;
  for (i = 1; i <= l; i++) {
    for (j = i; j <= l; j += i) {
      p[j].push_back(i);
    }
  }
  cin >> n;
  for (i = 1; i <= n; i++) {
    cin >> x >> y;
    t = 0;
    for (auto u : p[x]) {
      if (b[u] < i - y) t++;
      b[u] = i;
    }
    cout << t << "\n";
  }
  return 0;
}
