#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5;
const int M = 1e9 + 5;
int last[N];
int main() {
  int n;
  int x, y;
  cin >> n;
  memset(last, 0, sizeof(last));
  for (int i = 1; i <= n; i++) {
    cin >> x >> y;
    int k = (int)sqrt(x);
    int ans = 0;
    for (int j = 1; j <= k; j++) {
      if (x % j == 0) {
        if (i - last[j] > y) ans++;
        last[j] = i;
        if (i - last[x / j] > y) ans++;
        last[x / j] = i;
      }
    }
    cout << ans << endl;
  }
  return 0;
}
