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