#include <bits/stdc++.h>
using namespace std;
int N;
int mark[100010];
int x[100010][2];
int main() {
  cin >> N;
  for (int i = 1; i <= N; i++) {
    cin >> x[i][0] >> x[i][1];
    int sq = (int)sqrt((double)x[i][0]);
    int res = 0;
    if (sq * sq == x[i][0] && mark[sq] < i - x[i][1]) {
      res++;
      mark[sq] = i;
    }
    for (int j = 1; j <= sq; j++) {
      if (x[i][0] % j == 0) {
        if (mark[x[i][0] / j] < i - x[i][1]) res++;
        if (mark[j] < i - x[i][1]) res++;
        mark[j] = mark[x[i][0] / j] = i;
      }
    }
    cout << res << endl;
  }
  return 0;
}
