#include <bits/stdc++.h>
using namespace std;
vector<int> get_divisor(int x) {
  vector<int> divs;
  for (int i = 1; i <= ceil(sqrt(x)); i++) {
    if (x % i == 0) {
      divs.push_back(i);
      if (i * i == x) continue;
      divs.push_back(x / i);
    }
  }
  return divs;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int n;
  cin >> n;
  vector<int> last(100005, -1);
  for (int i = 0; i < n; i++) {
    int x, y;
    cin >> x >> y;
    vector<int> divisors = get_divisor(x);
    int ans = 0;
    for (auto &z : divisors) {
      if (last[z] >= i - y)
        ;
      else
        ans++;
      last[z] = i;
    }
    cout << ans << "\n";
  }
  return 0;
}
