#include <bits/stdc++.h>
const int N = 100000 + 10;
int app[N];
int main() {
  memset(app, 0, sizeof app);
  int n, x, y, cnt;
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i) {
    scanf("%d%d", &x, &y);
    cnt = 0;
    for (int j = 1; j * j <= x; ++j)
      if (x % j == 0) {
        if (app[j] < i - y) ++cnt;
        app[j] = i;
        if (j * j != x) {
          if (app[x / j] < i - y) ++cnt;
          app[x / j] = i;
        }
      }
    printf("%d\n", cnt);
  }
  return 0;
}
