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