#include <bits/stdc++.h>
using namespace std;
const int infinity = 0x3fffffff, maxn = 100101;
const long long linfinity = 0x3fffffffffffffffLL;
int n, x_index[maxn];
extern vector<int>* get_divs(int);
extern void init(void);
int main() {
  init();
  scanf("%d", &n);
  for (int i = 0; i < maxn; ++i) x_index[i] = -1;
  for (int i = 0, x, y; i < n; i++) {
    scanf("%d%d", &x, &y);
    vector<int>* divs = get_divs(x);
    int v_count = 0;
    for (int j = 0, d, sz = divs->size(); j < sz; ++j) {
      d = divs->at(j);
      v_count += x_index[d] < i - y;
      x_index[d] = i;
    }
    printf("%d\n", v_count);
  }
  return 0;
}
vector<int> divs[maxn];
void init(void) {
  for (int i = 0; i < maxn; ++i) divs[i].clear();
  for (int i = 1; i < maxn; ++i)
    for (int j = i; j < maxn; j += i) divs[j].push_back(i);
  return;
}
vector<int>* get_divs(int n) { return &(divs[n]); }
