#include <bits/stdc++.h>
using namespace std;
int last[100005];
int divs[1000];
int main() {
  int i, j, k, tests, cs = 0, n;
  scanf("%d", &n);
  memset(last, (-1), sizeof(last));
  for (i = 0; i < n; i++) {
    int x, y, tot = 0, ans = 0;
    scanf("%d%d", &x, &y);
    for (j = 1; j * j <= x; j++) {
      if (x % j) continue;
      if (last[j] < i - y) ans++;
      last[j] = i;
      if (j * j == x) continue;
      k = x / j;
      if (last[k] < i - y) ans++;
      last[k] = i;
    }
    printf("%d\n", ans);
  }
  return 0;
}
