#include <bits/stdc++.h>
using namespace std;
vector<int> a[100010];
int y[100010], res[100010];
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    int num;
    scanf("%d%d", &num, &y[i]);
    res[i] = 0;
    for (int k = 1; k * k <= num; k++)
      if (num % k == 0) {
        a[k].push_back(i);
        res[i]++;
        if (k * k != num) {
          a[num / k].push_back(i);
          res[i]++;
        }
      }
  }
  for (int i = 1; i <= 100000; i++)
    for (int j = 1; j < a[i].size(); j++)
      if (a[i][j] - a[i][j - 1] <= y[a[i][j]]) res[a[i][j]]--;
  for (int i = 0; i < n; i++) printf("%d\n", res[i]);
  return 0;
}
