#include <bits/stdc++.h>
using namespace std;
const long long OO = (long long)5e18 + 7;
using namespace std;
long long inv(long long a, long long b) {
  return 1 < a ? b - inv(b % a, a) * b / a : 1;
}
long long Pow(long long B, long long P) {
  long long R = 1;
  while (P > 0) {
    if (P & 1) R = (R * B);
    P /= 2;
    B = (B * B);
  }
  return R;
}
long long GCD(long long a, long long b) {
  while (b) {
    b ^= a ^= b ^= a %= b;
  }
  return a;
}
long long LCM(long long a, long long b) { return (a / GCD(a, b) * b); }
long long BigMod(long long B, long long P, long long M) {
  long long R = 1;
  while (P > 0) {
    if (P & 1) {
      R = (R * B) % M;
    }
    P /= 2;
    B = (B * B) % M;
  }
  return (long long)R;
}
vector<long long> generate_divisors(long long n) {
  vector<long long> v;
  long long i;
  for (i = 1; i * i <= n; ++i)
    if (n % i == 0) v.push_back(i), v.push_back(n / i);
  if (i * i == n) v.push_back(i);
  return v;
}
vector<long long> pr(100005, -1);
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int n;
  cin >> n;
  for (long long i = 0; i < n; ++i) {
    int x, y;
    cin >> x >> y;
    vector<long long> v = generate_divisors(x);
    int ans = v.size();
    for (long long t : v) {
      if (i - pr[t] <= y) --ans;
      pr[t] = i;
    }
    cout << ans << "\n";
  }
  return 0;
}
