#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1e5 + 5;
const int INF = 2e9;
const int MOD = 1e9 + 7;
int arr[MAXN], used[MAXN];
int main() {
  int N = 0, M = 0;
  scanf("%i", &N);
  for (int i = 1; i <= N; i++) {
    int RES = 0;
    scanf("%i%i", &arr[i], &M);
    for (int j = 1; j * j <= arr[i]; j++)
      if (arr[i] % j == 0) {
        if (used[j] < i - M) RES++;
        used[j] = i;
        if (j * j != arr[i]) {
          if (used[arr[i] / j] < i - M) RES++;
          used[arr[i] / j] = i;
        }
      }
    printf("%i\n", RES);
  }
  return 0;
}
