#include <bits/stdc++.h>
using namespace std;
int used[100005], x, y;
void solve(int idx) {
  int ans = 0;
  for (int i = 1; i * i <= x; i++) {
    if (x % i == 0) {
      int d = x / i;
      if (used[i] < idx - y) ans++;
      if (x % d == 0 && d != i) {
        if (used[d] < idx - y) ans++;
        used[d] = idx;
      }
      used[i] = idx;
    }
  }
  cout << ans << "\n";
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  for (int i = 0; i < 100005; i++) used[i] = -1;
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> x >> y;
    solve(i);
  }
  return 0;
}
