#include <bits/stdc++.h>
using namespace std;
const int MAXN = 100050;
int m[MAXN];
int main() {
  int n;
  scanf("%d", &n);
  memset(m, -1, sizeof(m));
  for (int i = 1; i <= n; i++) {
    int x, y;
    scanf("%d %d", &x, &y);
    int cnt = 0;
    for (int j = 1; j * j <= x; j++) {
      if (x % j != 0) continue;
      if (m[j] == -1)
        cnt++;
      else if (!(i - y <= m[j] && m[j] < i))
        cnt++;
      m[j] = i;
      if (m[x / j] == -1)
        cnt++;
      else if (x != j * j && !(i - y <= m[x / j] && m[x / j] < i))
        cnt++;
      m[x / j] = i;
    }
    printf("%d\n", cnt);
  }
  return 0;
}
