#include <bits/stdc++.h>
using namespace std;
long long int last_seen[100005];
int main() {
  long long int t, j;
  cin >> t;
  for (long long int i = 1; i <= t; i++) {
    long long int x, y;
    cin >> x >> y;
    long long int count = 0;
    for (j = 1; j * j < x; j++) {
      if (x % j == 0) {
        if (i - last_seen[j] > y) count++;
        last_seen[j] = i;
        long long int k = x / j;
        if (i - last_seen[k] > y) count++;
        last_seen[k] = i;
      }
    }
    if (x % j == 0) {
      if (i - last_seen[j] > y) count++;
      last_seen[j] = i;
    }
    cout << count << endl;
  }
  return 0;
}
