#include <bits/stdc++.h>
using namespace std;
const int N = 5e5 + 5;
int last[N];
std::vector<int> v[N];
void init() {
  for (int i = 1; i < N; ++i)
    for (int j = 1; i * j < N; ++j) v[i * j].push_back(i);
}
int main(void) {
  int n;
  scanf("%d", &n);
  init();
  for (int i = 1; i <= n; ++i) {
    int ans = 0;
    int x, y;
    scanf("%d%d", &x, &y);
    for (auto it : v[x])
      if (i - last[it] > y) ans = ans + 1;
    printf("%d\n", ans);
    for (auto it : v[x]) last[it] = i;
  }
}
