#include <bits/stdc++.h>
using namespace std;
const int N = 100004;
int pos[N];
int main() {
  int x, y, n, t, ans;
  scanf("%d", &n);
  for (int q = 1; q <= n; q++) {
    scanf("%d %d", &x, &y);
    ans = 0;
    for (int i = 1; i * i <= x; i++)
      if (x % i == 0) {
        if (q - pos[i] > y) ++ans;
        t = x / i;
        pos[i] = q;
        if (t == i) continue;
        if (q - pos[t] > y) ++ans;
        pos[t] = q;
      }
    printf("%d\n", ans);
  }
}
