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