#include <bits/stdc++.h>
using namespace std;
int main() {
  cin.tie(0)->sync_with_stdio(0);
  cin.exceptions(cin.failbit);
  int n;
  cin >> n;
  vector<int> last(1e5 + 1, -1);
  for (int i = 0; i < (n); ++i) {
    int x, y;
    cin >> x >> y;
    int cnt = 0;
    for (int j = 1; j < (sqrt(x) + 1); ++j) {
      if (x % j == 0) {
        if (last[j] < i - y) cnt++;
        last[j] = i;
        if (j * j != x) {
          if (last[x / j] < i - y) cnt++;
          last[x / j] = i;
        }
      }
    }
    cout << cnt << "\n";
  }
}
