#include <bits/stdc++.h>
using namespace std;
const long MAXX = 100050;
int d[MAXX];
int main() {
  int n;
  cin >> n;
  long x, y;
  for (int i = 0; i < MAXX; ++i) d[i] = -1;
  for (int i = 0; i < n; ++i) {
    cin >> x >> y;
    int result = 0;
    for (int j = 1; j * j <= x; ++j) {
      if (x % j) continue;
      if (d[j] < i - y) result++;
      d[j] = i;
      if (d[x / j] < i - y) result++;
      d[x / j] = i;
    }
    cout << result << endl;
  }
  return 0;
}
