#include <bits/stdc++.h>
using namespace std;
long n, lst[200000], a, b, ans;
long gb;
void check(long x) {
  if (lst[x] < b) ++ans;
  lst[x] = gb;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin >> n;
  for (int j = 1; j <= 100000; j++) lst[j] = -1;
  for (int i = 1; i <= n; i++) {
    gb = i;
    cin >> a >> b;
    b = i - b;
    ans = 0;
    for (int j = 1; j * j <= a; j++) {
      if (a % j == 0) {
        check(j);
        if (a / j != j) check(a / j);
      }
    }
    cout << ans << endl;
  }
  cin.get();
  cin.get();
  return 0;
}
