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