#include <bits/stdc++.h>
int main() {
  int n, i, j;
  int x, y;
  int sqrtX;
  int sum = 0;
  int checkArr[100002];
  for (i = 0; i < 100002; i++) checkArr[i] = -1;
  scanf("%d", &n);
  for (i = 0; i < n; i++) {
    sum = 0;
    scanf("%d %d", &x, &y);
    sqrtX = (int)sqrt(x);
    for (j = 1; j <= sqrtX + 2; j++) {
      if (x % j == 0) {
        if (checkArr[j] < i - y) {
          sum += 1;
        } else {
        }
        if (x / j != j && checkArr[x / j] < i - y) {
          sum += 1;
        } else {
        }
        checkArr[j] = i;
        checkArr[x / j] = i;
      }
    }
    printf("%d\n", sum);
  }
  return 0;
}
