#include <bits/stdc++.h>
using namespace std;
int last[100010];
int main() {
  int n;
  scanf("%d", &n);
  memset(last, -1, sizeof last);
  for (int i = 0; i < n; i++) {
    int x, y;
    scanf("%d%d", &x, &y);
    int gen = (int)sqrt((double)x);
    int cnt = 0;
    for (int j = 1; j <= gen; j++) {
      int jj = j;
      for (int k = 0; k < 2; k++) {
        if (k == 1) jj = x / j;
        if (x % jj == 0) {
          if (last[jj] == -1 || (last[jj] != -1 && i - last[jj] > y)) {
            cnt++;
          }
          last[jj] = i;
        }
      }
    }
    printf("%d\n", cnt);
  }
  return 0;
}
