#include <bits/stdc++.h>
using namespace std;
int n;
int first[100100], second[100100], res[100100];
vector<int> occ[100100];
void add(int first, int pos) {
  for (int d = 1; d * d <= first; d++)
    if (first % d == 0) {
      occ[d].push_back(pos);
      if (d != first / d) occ[first / d].push_back(pos);
    }
}
int main() {
  scanf("%d", &n);
  for (int i = 0; i < (n); i++) scanf("%d%d", &first[i], &second[i]);
  for (int i = 0; i < (n); i++) add(first[i], i);
  for (int i = 0; i < (100100); i++) {
    if (occ[i].size() == 0) continue;
    res[occ[i][0]]++;
    for (int j = 1; j < occ[i].size(); j++) {
      int back = second[occ[i][j]];
      if (occ[i][j - 1] < occ[i][j] - back) res[occ[i][j]]++;
    }
  }
  for (int i = 0; i < (n); i++) printf("%d\n", res[i]);
}
