#include <bits/stdc++.h>
using namespace std;
inline int max(int a, int b) { return a > b ? a : b; }
inline int min(int a, int b) { return a < b ? a : b; }
int ok[100005];
int main() {
  memset(ok, -1, sizeof(ok));
  int n, x, y;
  cin >> n;
  for (int i(1); i <= (n); ++i) {
    cin >> x >> y;
    int cnt(0);
    for (int j(1); j <= (sqrt(x)); ++j)
      if (x % j == 0) {
        if (j * j == x)
          cnt += (ok[j] < i - y), ok[j] = i;
        else
          cnt += (ok[j] < i - y) + (ok[x / j] < i - y), ok[j] = ok[x / j] = i;
      }
    cout << cnt << endl;
  }
  return 0;
}
