#include <bits/stdc++.h>
using namespace std;
vector<int> G[100005];
int main() {
  int n;
  cin >> n;
  vector<int> ans;
  for (int i = 0; i < n; i++) {
    int x, y;
    cin >> x >> y;
    vector<int> div;
    for (int j = 1; j * j <= x; j++) {
      if (x % j == 0) {
        int div1 = j;
        int div2 = x / j;
        div.push_back(div1);
        if (div1 != div2) div.push_back(div2);
      }
    }
    for (int j = 0; j < (int)(div.size()); j++) {
      G[div[j]].push_back(i);
    }
    if (y == 0)
      ans.push_back((int)(div.size()));
    else {
      int l = i - y;
      int r = i - 1;
      int cnt = 0;
      for (int j = 0; j < (int)(div.size()); j++) {
        int d = div[j];
        int ind1 = lower_bound(G[d].begin(), G[d].end(), l) - G[d].begin();
        int ind2 = upper_bound(G[d].begin(), G[d].end(), r) - G[d].begin();
        if (ind1 == ind2) cnt++;
      }
      ans.push_back(cnt);
    }
  }
  for (int i = 0; i < (int)(ans.size()); i++) cout << ans[i] << endl;
  return 0;
}
