#include <bits/stdc++.h>
int n, p[1000 * 100 + 1000];
int x, y, ans, j;
int main() {
  std::cin >> n;
  for (int i = 1; i < n + 1; i++) {
    std::cin >> x >> y;
    ans = 0;
    for (j = 1; j * j <= x; j++)
      if (x % j == 0) {
        if (p[(j)] < i - y) ans++;
        p[(j)] = i;
        ;
        if (p[(x / j)] < i - y) ans++;
        p[(x / j)] = i;
        ;
      }
    std::cout << ans << "\n";
  }
}
