#include <bits/stdc++.h>
using namespace std;
const int OO = 0x3f3f3f3f, N = 1e5 + 5, mod = 1e9 + 7;
const double pi = acos(-1), EPS = 1e-8;
int n, x, y, idx[N];
int main() {
  memset(idx, -1, sizeof idx);
  scanf("%d", &n);
  for (int t = 1; t <= n; ++t) {
    scanf("%d%d", &x, &y);
    int cnt = 0;
    for (int i = 1; i * i <= x; ++i)
      if (x % i == 0) {
        cnt += (idx[i] < t - y) + (i * i != x && idx[x / i] < t - y);
        idx[i] = idx[x / i] = t;
      }
    printf("%d\n", cnt);
  }
  return 0;
}
