#include <bits/stdc++.h>
using namespace std;
const int maxn = 218 * 1000;
int d[maxn];
int main() {
  memset(d, -1, sizeof(d));
  int n;
  cin >> n;
  for (int i = 0; i < n; ++i) {
    int x, y;
    cin >> x >> y;
    int res = 0;
    for (int j = 1; j * j <= x; ++j) {
      if (x % j) continue;
      int k = j;
      if (d[k] < i - y) ++res;
      d[k] = i;
      if (j != x / j) {
        k = x / j;
        if (d[k] < i - y) ++res;
        d[k] = i;
      }
    }
    printf("%d\n", res);
  }
  return 0;
}
