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