#include <bits/stdc++.h>
const long double eps = 1e-9;
const double pi = acos(-1.0);
const long long inf = 1e18;
using namespace std;
int last[111111], n, x, y, ans;
int main(int argc, const char* argv[]) {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d%d", &x, &y);
    ans = 0;
    for (int j = 1; j * j <= x; j++) {
      if (x % j != 0) continue;
      if (last[j] < i - y) ++ans;
      if (last[x / j] < i - y && j != x / j) ++ans;
      last[j] = last[x / j] = i;
    }
    printf("%d\n", ans);
  }
  return 0;
}
