#include <bits/stdc++.h>
using namespace std;
vector<int> fact[100001];
vector<int> divx(int x) {
  vector<int> ret;
  ret.push_back(1);
  if (x != 1) ret.push_back(x);
  for (int i = 2; i <= sqrt(x); i++) {
    if (x % i == 0) {
      ret.push_back(i);
      if (i * i != x) ret.push_back(x / i);
    }
  }
  return ret;
}
int main(int argc, char *argv[]) {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    int x, y;
    scanf("%d %d", &x, &y);
    vector<int> div = divx(x);
    if (y == 0)
      printf("%d\n", div.size());
    else {
      int ans = 0;
      int lb = (i + 1) - y;
      int hb = i;
      for (int j = 0; j < div.size(); j++) {
        vector<int>::iterator it =
            lower_bound(fact[div[j]].begin(), fact[div[j]].end(), lb);
        if (it == fact[div[j]].end()) ans++;
      }
      printf("%d\n", ans);
    }
    for (int j = 0; j < div.size(); j++) fact[div[j]].push_back(i + 1);
  }
  return 0;
}
