#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 50;
int n, last[N];
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  for (int i = 1, x, y; i <= n; i++) {
    int ans = 0;
    cin >> x >> y;
    for (int j = 1; j * j <= x; j++) {
      if (x % j) continue;
      ans += (last[j] < i - y);
      if (x / j != j) ans += (last[x / j] < i - y);
      last[j] = last[x / j] = i;
    }
    cout << ans << '\n';
  }
}
