#include <bits/stdc++.h>
using namespace std;
vector<long long> fact(10, 1);
long long gcd(long long n1, long long n2) {
  long long maxm = max(n1, n2);
  long long minm = min(n1, n2);
  if ((maxm % minm) == 0)
    return minm;
  else
    return gcd(minm, maxm % minm);
}
long long power(long long x, long long y) {
  long long temp;
  if (y == 0) return 1;
  temp = power(x, y / 2) % 1000000007;
  if (y % 2 == 0)
    return temp * temp % 1000000007;
  else
    return (x * temp % 1000000007) * temp % 1000000007;
}
long long ifact(long long k) {
  return power(fact[k], 1000000007 - 2) % 1000000007;
}
long long ncr(long long n, long long r) {
  if (n < r) return 0;
  long long num = 1;
  long long den = 1;
  long long g;
  for (long long i = 1; i < r + 1; i++) {
    num = num * (n - i + 1);
    den = den * (i);
    g = gcd(num, den);
    num = num / g;
    den = den / g;
  }
  return num;
}
vector<long long> factors(100001, -1);
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int t = 1;
  while (t--) {
    long long n, x, y;
    cin >> n;
    for (long long i = 0; i < n; i++) {
      long long ans = 0;
      cin >> x >> y;
      for (long long j = 1; j < sqrt(x); j++) {
        if (x % j == 0) {
          if (factors[j] == -1 || factors[j] < i - y) ans++;
          factors[j] = i;
          if (factors[x / j] == -1 || factors[x / j] < i - y) ans++;
          factors[x / j] = i;
        }
      }
      long long sq = sqrt(x);
      if (sq * sq == x) {
        if (factors[sq] == -1 || factors[sq] < i - y) ans++;
        factors[sq] = i;
      }
      cout << ans << endl;
    }
  }
}
