#include <bits/stdc++.h>
using namespace std;
vector<int> divs[100010];
int main() {
  int i, j;
  int n, x, y;
  scanf("%d", &n);
  for (i = 0; i < n; ++i) {
    scanf("%d %d", &x, &y);
    int res = 0;
    for (j = 1; j * j <= x; ++j) {
      if (x % j == 0) {
        if (lower_bound(divs[j].begin(), divs[j].end(), i - y) == divs[j].end())
          ++res;
        divs[j].push_back(i);
        if (j * j != x) {
          int d = x / j;
          if (lower_bound(divs[d].begin(), divs[d].end(), i - y) ==
              divs[d].end())
            ++res;
          divs[d].push_back(i);
        }
      }
    }
    printf("%d\n", res);
  }
  return 0;
}
