#include <bits/stdc++.h>
using namespace std;
int main() {
  cin.tie(0);
  cin.sync_with_stdio(0);
  vector<long long> D(100001, -1);
  int n;
  cin >> n;
  for (long long i = 0; i < (n); i++) {
    int x, y;
    cin >> x >> y;
    int ans = 0;
    for (int d = 1; d * d <= x; d++) {
      if (x % d) continue;
      if (D[d] < i - y) ans++;
      if (D[x / d] < i - y && d != x / d) ans++;
      D[d] = D[x / d] = i;
    }
    cout << ans << '\n';
  }
  return 0;
}
