#include <bits/stdc++.h>
using namespace std;
bool isprime[400];
int primes[400];
int sz;
inline void precompute() {
  for (int i = 2; i * i < 400; i++) {
    if (!isprime[i])
      for (int j = i * i; j < 400; j += i) isprime[j] = 1;
  }
  for (int i = 2; i < 400; i++)
    if (!isprime[i]) primes[sz++] = i;
}
int X[100001];
int Y[100001];
vector<int> A[100001];
int main() {
  precompute();
  int N;
  scanf("%d", &N);
  for (int i = 1; i <= N; i++) {
    scanf("%d %d", &X[i], &Y[i]);
    int x = X[i];
    int l = 0;
    vector<int> divisors;
    divisors.push_back(1);
    for (int j = 0; j < sz && x > 1; j++) {
      int p = primes[j];
      while (x % p == 0) {
        int tl = divisors.size();
        for (int z = 0; z < tl; z++) {
          int tmp = divisors[z] * p;
          divisors.push_back(tmp);
        }
        x /= p;
      }
    }
    if (x > 1) {
      int p = x;
      int tl = (int)divisors.size();
      for (int z = 0; z < tl; z++) {
        int tmp = divisors[z] * p;
        divisors.push_back(tmp);
      }
      x /= p;
    }
    sort(divisors.begin(), divisors.end());
    divisors.erase(unique(divisors.begin(), divisors.end()), divisors.end());
    if (Y[i] == 0)
      printf("%d\n", (int)divisors.size());
    else {
      int ret = 0;
      for (int z = 0; z < divisors.size(); z++) {
        int d = divisors[z];
        if (lower_bound(A[d].begin(), A[d].end(), i - Y[i]) == A[d].end())
          ret += 1;
      }
      printf("%d\n", ret);
    }
    for (int z = 0; z < divisors.size(); z++) {
      int d = divisors[z];
      A[d].push_back(i);
    }
  }
  return 0;
}
