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