#include <bits/stdc++.h>
using namespace std;
const int N = 100010;
int n;
int minp[N];
int main() {
  scanf("%d", &n);
  for (int i = 1, x, y; i <= n; i++) {
    scanf("%d%d", &x, &y);
    int s = 0;
    for (int j = 1; j * j <= x; j++) {
      if (x % j) continue;
      if (minp[j] < i - y) s++;
      if (x / j != j && minp[x / j] < i - y) s++;
      minp[j] = minp[x / j] = i;
    }
    printf("%d\n", s);
  }
  return 0;
}
