#include <bits/stdc++.h>
using namespace std;
int nn;
int ans;
int n, x, y, f[110000], cnt = 0;
void ini() {
  cnt = 0;
  cin >> n;
}
void work() {
  int temp;
  for (int i = 1; i <= n; i++) {
    cin >> x >> y;
    temp = sqrt(x);
    cnt = 0;
    for (int j = 1; j <= temp; j++) {
      if (x % j == 0) {
        if (i - f[j] > y) {
          cnt++;
        }
        if (i - f[x / j] > y && j != x / j) {
          cnt++;
        }
        f[j] = i;
        f[x / j] = i;
      }
    }
    cout << cnt << endl;
  }
}
int main() {
  ini();
  work();
  return 0;
}
