#include <bits/stdc++.h>
const int V = 100010;
int n;
int x[V], y[V], pos[V];
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d%d", &x[i], &y[i]);
  }
  for (int i = 1; i <= n; i++) {
    int ret = 0;
    for (int j = 1; j * j <= x[i]; j++)
      if (x[i] % j == 0) {
        int ta = j, tb = x[i] / j;
        if (pos[ta] < i - y[i]) ret++;
        pos[ta] = i;
        if (tb != ta) {
          if (pos[tb] < i - y[i]) ret++;
          pos[tb] = i;
        }
      }
    printf("%d\n", ret);
  }
}
