#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:64000000")
using namespace std;
const int N = 100000 + 42;
int last[N];
int main() {
  memset(last, -1, sizeof(last));
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    int x, y;
    scanf("%d%d", &x, &y);
    y = i - y;
    int ans = 0;
    for (int j = 1; j * j <= x; j++) {
      if (x % j) continue;
      int d1 = j;
      int d2 = x / j;
      if (last[d1] < y) ans++;
      if (last[d2] < y) ans++;
      if (d1 == d2 && last[d1] < y) ans--;
      last[d1] = i;
      last[d2] = i;
    }
    printf("%d\n", ans);
  }
  return 0;
}
