#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<int> count(1000001, -1);
  for (int i = 0; i < n; i++) {
    int x, y;
    cin >> x >> y;
    int ans = 0;
    for (int j = 1; j <= (int)(sqrt(x + 0.1)); j++) {
      if (x % j != 0) continue;
      if (count[j] < i - y) ans++;
      if (count[x / j] < i - y && x / j != j) ans++;
      count[j] = count[x / j] = i;
    }
    cout << ans << endl;
  }
  return 0;
}
