#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<int> answ(n);
  vector<int> lastSeen(100001, 0);
  for (int i = 1; i <= n; ++i) {
    int num, last;
    cin >> num >> last;
    long long numsq = sqrt(num);
    for (int divisor = 1; divisor <= numsq; ++divisor) {
      if (!(num % divisor)) {
        int div2 = num / divisor;
        if (lastSeen[divisor] < i - last) ++answ[i - 1];
        if (div2 != divisor && lastSeen[num / divisor] < i - last)
          ++answ[i - 1];
        lastSeen[divisor] = i;
        lastSeen[num / divisor] = i;
      }
    }
  }
  for (auto& num : answ) cout << num << endl;
  return 0;
}
