#include <bits/stdc++.h>
using namespace std;
int a[100010], q, x, y, ans;
int main() {
  memset(a, -1, sizeof a);
  cin >> q;
  for (int j = 0; j < q; j++) {
    ans = 0;
    cin >> x >> y;
    for (int i = 1; i * i <= x; i++) {
      if (x % i == 0) {
        if (a[i] + y < j) ans++;
        if (x / i != i && a[x / i] + y < j) ans++;
        a[i] = j;
        a[x / i] = j;
      }
    }
    cout << ans << endl;
  }
  return 0;
}
