#include <bits/stdc++.h>
using namespace std;
template <typename T>
T gcd(T a, T b) {
  if (a == 0) return b;
  return gcd(b % a, a);
}
template <typename T>
T pow(T a, T b, long long m) {
  T ans = 1;
  a = a % m;
  while (b > 0) {
    if (b % 2 == 1) ans = (ans * a) % m;
    b /= 2;
    a = (a * a) % m;
  }
  return ans % m;
}
template <typename T>
T modInv(T a, T m) {
  return pow(a, m - 2, m);
}
const int MAX = 100005;
int primeDivisor[MAX];
bool isPrime[MAX];
vector<int> primes;
void sieve() {
  for (int i = 2; i < MAX; i++) primeDivisor[i] = i;
  for (int i = 2; i < MAX; i++) {
    if (primeDivisor[i] != i) continue;
    for (int j = 2 * i; j < MAX; j += i) primeDivisor[j] = i;
  }
  for (int i = 2; i < MAX; i++) isPrime[i] = (primeDivisor[i] == i);
  for (int i = 2; i < MAX; i++)
    if (isPrime[i]) primes.push_back(i);
}
set<int> divisors(int n) {
  if (n == 1) {
    set<int> out;
    out.insert(1);
    return out;
  }
  int factor = primeDivisor[n];
  int factor2 = n / factor;
  set<int> out = divisors(factor2);
  vector<int> extra;
  for (auto div : out) extra.push_back(div * factor);
  for (auto div : extra) out.insert(div);
  return out;
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n;
  cin >> n;
  int last[100005];
  for (int i = 0; i <= 100005; i++) last[i] = 0;
  sieve();
  for (int i = 1; i <= n; i++) {
    int x, y;
    cin >> x >> y;
    int ans = 0;
    int lim = i - y;
    for (auto div : divisors(x)) {
      if (last[div] < lim) ans++;
      last[div] = i;
    }
    cout << ans << "\n";
  }
  return 0;
}
