#include <bits/stdc++.h>
using namespace std;
vector<long long> DIV[100010];
long long lst[100010];
void gen() {
  for (long long i = 1; i < 100010; i++) {
    lst[i] = -1e15;
    for (long long j = i; j < 100010; j += i) {
      DIV[j].push_back(i);
    }
  }
}
int main() {
  gen();
  long long n;
  scanf("%lld", &n);
  for (long long i = 1; i <= n; i++) {
    long long x, y;
    scanf("%lld", &x);
    scanf("%lld", &y);
    long long f = 0;
    for (long long j = 0; j < DIV[x].size(); j++) {
      long long d = DIV[x][j];
      if (lst[d] < (i - y)) f++;
      lst[d] = i;
    }
    printf("%lld\n", f);
  }
  return 0;
}
