#include <bits/stdc++.h>
using namespace std;
vector<long long> dv[100009];
long long ase[100009];
int main() {
  for (long long i = 1; i <= 100005; i++) {
    for (long long j = i; j <= 100005; j += i) dv[j].push_back(i);
  }
  long long n;
  cin >> n;
  for (long long i = 1; i <= n; i++) {
    long long x, y;
    scanf("%lld %lld", &x, &y);
    long long ans = 0;
    for (long long j = 0; j < dv[x].size(); j++) {
      long long l = i - y, r = i - 1;
      if (!(ase[dv[x][j]] >= l && ase[dv[x][j]] <= r)) ans++;
      ase[dv[x][j]] = i;
    }
    if (y == 0) {
      printf("%lld\n", (long long)(dv[x].size()));
      continue;
    } else {
      printf("%lld\n", ans);
    }
  }
  return 0;
}
