#include <bits/stdc++.h>
using namespace std;
int ar[100010];
int pre[100010];
vector<int> getdiv(int k) {
  vector<int> ans;
  for (long long i = 1; i * i <= k; i++) {
    if (k % i == 0) {
      if (i == k / i)
        ans.push_back(i);
      else {
        ans.push_back(i);
        ans.push_back(k / i);
      }
    }
  }
  return ans;
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    int x, y;
    cin >> x >> y;
    vector<int> ans = getdiv(x);
    int val = 0;
    for (auto it : ans) {
      if (!pre[it] || pre[it] < i - y) val++;
    }
    cout << val << "\n";
    for (auto it : ans) pre[it] = i;
  }
  return 0;
}
