#include <bits/stdc++.h>
using namespace std;
int n;
int last_pos[100005];
vector<int> divi[100005];
void pre() {
  for (int i = 1; i <= 100000; i++) {
    for (int j = i; j <= 100000; j += i) {
      divi[j].push_back(i);
    }
  }
}
int main() {
  pre();
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    int x, y;
    scanf("%d", &x);
    scanf("%d", &y);
    if (y == 0) {
      printf("%d\n", (int)divi[x].size());
    } else {
      int le = i - y;
      int ri = i - 1;
      int ans = 0;
      for (int j = 0; j < divi[x].size(); j++) {
        int now_divi = divi[x][j];
        if (last_pos[now_divi] >= le && last_pos[now_divi] <= ri) {
          continue;
        }
        ans++;
      }
      printf("%d\n", ans);
    }
    for (int j = 0; j < divi[x].size(); j++) {
      last_pos[divi[x][j]] = i;
    }
  }
  return 0;
}
