#include <bits/stdc++.h>
using namespace std;
const int mxn = 100007;
vector<int> factors[mxn];
int last[mxn];
int main(int argc, char** argv) {
  for (int f = 1; f < mxn; f++)
    for (int n = f; n < mxn; n += f) factors[n].push_back(f);
  for (int i = 0; i < mxn; i++) last[i] = -1;
  int queries;
  scanf("%d", &queries);
  for (int qi = 0; qi < queries; qi++) {
    int num;
    scanf("%d", &num);
    int index;
    scanf("%d", &index);
    int lo = qi - index;
    int cnt = 0;
    for (int j = 0; j < factors[num].size(); j++) {
      int f = factors[num][j];
      if (last[f] < lo) {
        cnt++;
      }
    }
    for (int j = 0; j < factors[num].size(); j++) {
      last[factors[num][j]] = qi;
    }
    printf("%d\n", cnt);
  }
  return 0;
}
