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