#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n, x, y, ans, k, l[100001]{0};
  cin >> n;
  for (int i = 1; i <= n; ++i) {
    ans = 0;
    cin >> x >> y;
    for (int64_t j = 1; j * j <= x; ++j) {
      if (x % j == 0) {
        if (l[j] < i - y) ++ans;
        l[j] = i;
        k = x / j;
        if (k == j) continue;
        if (l[k] < i - y) ++ans;
        l[k] = i;
      }
    }
    cout << ans << '\n';
  }
}
