#include <bits/stdc++.h>
using namespace std;
long long n, i, j, k, x, y, col;
vector<long long> ans;
long long last[100100];
int main() {
  cin >> n;
  for (i = 0; i < n; i++) {
    cin >> x >> y;
    col = 0;
    j = 1;
    while (j * j <= x) {
      if (x % j == 0) {
        k = x / j;
        if (last[j] < i - y + 1) {
          last[j] = i + 1;
          col++;
        }
        last[j] = i + 1;
        if (k != j && last[k] < i - y + 1) {
          col++;
        }
        last[k] = i + 1;
      }
      j++;
    }
    ans.push_back(col);
  }
  for (i = 0; i < n; i++) cout << ans[i] << endl;
  return 0;
}
