#include <bits/stdc++.h>
using namespace std;
const int mxn = 1e5 + 10;
vector<int> f[mxn];
int lt[mxn];
int main() {
  for (int i = 1; i < mxn; ++i) {
    for (int j = i; j < mxn; j += i) f[j].push_back(i);
    lt[i] = -(int)1e9;
  }
  int q, x, y;
  scanf("%d", &q);
  for (int i = 1; i <= q; ++i) {
    scanf("%d%d", &x, &y);
    int ret = 0;
    for (int d : f[x]) {
      ret += lt[d] < i - y;
      lt[d] = i;
    }
    printf("%d\n", ret);
  }
}
