#include <bits/stdc++.h>
using namespace std;
int table[100001];
vector<int> DIV[100001];
vector<int> getDiv(int n) {
  vector<int> ret;
  ret.push_back(1);
  for (int i = 2; i * 2 <= n; ++i)
    if (n % i == 0) ret.push_back(i);
  ret.push_back(n);
  return ret;
}
void initDIV() {
  for (int i = 1; i <= 100000; ++i) {
    for (int j = i; j <= 100000; j += i) {
      DIV[j].push_back(i);
    }
  }
}
int main() {
  initDIV();
  for (int i = 0; i <= 100000; ++i) table[i] = -1;
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; ++i) {
    int x, y;
    scanf("%d%d", &x, &y);
    vector<int> div = DIV[x];
    int cnt = 0;
    for (int j = 0; j < div.size(); ++j) {
      if (table[div[j]] < i - y) {
        cnt++;
      }
      table[div[j]] = i;
    }
    printf("%d\n", cnt);
  }
  return 0;
}
