#include <bits/stdc++.h>
using namespace std;
int main() {
  int arr[100005], n, x, y, i, cnt, pos, round;
  while (scanf("%d", &n) == 1) {
    for (i = 1; i <= 100000; i++) {
      arr[i] = 0;
    }
    for (round = 1; round <= n; round++) {
      scanf("%d%d", &x, &y);
      cnt = 0;
      pos = round - y;
      for (i = 1; (i * i) <= x; i++) {
        if (x % i == 0) {
          if (arr[i] == 0 || pos > arr[i]) {
            cnt++;
            arr[i] = round;
          } else {
            arr[i] = round;
          }
          if (arr[x / i] == 0 || pos > arr[x / i]) {
            cnt++;
            arr[x / i] = round;
          } else {
            arr[x / i] = round;
          }
        }
      }
      printf("%d\n", cnt);
    }
  }
  return 0;
}
