#include <bits/stdc++.h>
using namespace std;
const int N = 100100;
vector<int> dv[N];
map<int, int> all;
void f(int x) {
  dv[x].clear();
  for (int i = 1; i * i <= x; i++)
    if (x % i == 0) {
      dv[x].push_back(i);
      if (x / i != i) dv[x].push_back(x / i);
    }
}
int main() {
  for (int i = 1; i < N; i++) f(i);
  int n, x, y;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    int ans = 0;
    scanf("%d %d", &x, &y);
    for (auto d : dv[x]) {
      if (all.find(d) != all.end())
        if (all[d] >= i - y) ans++;
      all[d] = i;
    }
    printf("%d\n", dv[x].size() - ans);
  }
  return 0;
}
