#include <bits/stdc++.h>
using namespace std;
const int maxn = 100005;
int pos[maxn];
int n, x, y;
int main() {
  int i, j;
  while (scanf("%d", &n) != EOF) {
    memset(pos, -1, sizeof(pos));
    for (i = 1; i <= n; i++) {
      scanf("%d%d", &x, &y);
      int ans = 0;
      for (j = 1; j * j <= x; j++) {
        if (x % j == 0) {
          if (y == 0) {
            ans++;
            pos[j] = i;
            if (x / j != j) ans++;
            pos[x / j] = i;
            continue;
          }
          if (pos[j] < i - y) ans++;
          pos[j] = i;
          if (x / j != j && pos[x / j] < i - y) ans++;
          pos[x / j] = i;
        }
      }
      printf("%d\n", ans);
    }
  }
  return 0;
}
