#include <bits/stdc++.h>
int main(int argc, const char* argv[]) {
  int n;
  std::cin >> n;
  std::vector<int> b(100001);
  for (int i = 1; i <= n; ++i) {
    int x, y;
    std::cin >> x >> y;
    int counter = 0;
    for (int j = 1; j * j <= x; j++) {
      if (x % j == 0) {
        int j2 = x / j;
        if (b[j] < i - y) {
          counter++;
        }
        if (j2 != j && b[j2] < i - y) {
          counter++;
        }
        b[j] = i;
        b[j2] = i;
      }
    }
    std::cout << counter << std::endl;
  }
  return 0;
}
