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