#include <bits/stdc++.h>
using namespace std;
int m[100002];
int main() {
  memset(m, 255, sizeof m);
  int runs;
  scanf("%d", &runs);
  for (int j = 0; j < runs; j++) {
    int x, y, ret = 0;
    scanf("%d%d", &x, &y);
    for (int i = 1; i * i <= x; i++)
      if (x % i == 0) {
        if (m[i] < j - y) ret++;
        if (i * i < x && m[x / i] < j - y) ret++;
        m[i] = j;
        m[x / i] = j;
      }
    printf("%d\n", ret);
  }
  return 0;
}
