#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  scanf("%d", &n);
  vector<int> LAST(100100, -1);
  for (int test = (0); test < (n); ++test) {
    int x, y;
    scanf("%d%d", &x, &y);
    vector<int> dv;
    int TO = (int)sqrt(1.0 * x);
    for (int i = (1); i < (TO + 1); ++i) {
      if (x % i == 0) {
        dv.push_back(i);
        dv.push_back(x / i);
      }
    }
    int t = (int)sqrt(1.0 * x);
    int res = int((dv).size());
    int last = test - y;
    for (int i = (0); i < (int((dv).size())); ++i) {
      if (LAST[dv[i]] >= last) res--;
      LAST[dv[i]] = test;
    }
    printf("%d\n", res);
  }
  return 0;
}
