#include <bits/stdc++.h>
using namespace std;
int read() {
  int n;
  char c;
  bool neg;
  n = 0;
  neg = false;
  for (c = getchar(); !(c >= '0' && c <= '9') && c != '-'; c = getchar())
    ;
  if (c == '-') {
    neg = true;
    c = getchar();
  }
  while ((c >= '0' && c <= '9')) {
    n = n * 10 + c - '0';
    c = getchar();
  }
  return neg ? -n : n;
}
int main() {
  int i, n, a, b, aa, j, k;
  int v[100000 + 1];
  memset(v, -1, sizeof v);
  cin >> n;
  for (i = (0); i < (n); i++) {
    cin >> a >> b;
    j = 1;
    k = 0;
    while (j * j <= a) {
      if (a % j == 0) {
        if (v[j] < i - b) {
          k++;
        }
        v[j] = i;
        if (v[a / j] < i - b) {
          k++;
        }
        v[a / j] = i;
      }
      j++;
    }
    cout << k << endl;
  }
  return 0;
}
