#include <bits/stdc++.h>
using namespace std;
int g[100005] = {};
int main() {
  int n;
  cin >> n;
  memset(g, -1, sizeof(g));
  for (int i = 0; i < n; i++) {
    int x, y;
    cin >> x >> y;
    int cnt = 0;
    for (int j = 1; j * j <= x; j++) {
      if ((x % j) == 0) {
        int k = x / j;
        if (g[j] < i - y) {
          cnt++;
        }
        if (j != k && g[k] < i - y) {
          cnt++;
        }
        g[k] = i;
        g[j] = i;
      }
    }
    cout << cnt << endl;
  }
  return 0;
}
