#include <bits/stdc++.h>
const long long oo = (long long)1e18;
using namespace std;
int dvs[100002], mu[100002], last[100002], prime[10001], plist[10001], dem;
void check(int x, int d) {
  if (x == 1) {
    dem++;
    plist[dem] = d;
    return;
  }
  int b = x / mu[x];
  for (int k = 1; k <= mu[x];) {
    check(b, k * d);
    if (k == mu[x]) break;
    k *= prime[dvs[x]];
  }
}
int main() {
  int n, x, y, pr = 0;
  dvs[1] = 1;
  mu[1] = 1;
  for (int i = (2); i <= (100000); i++) {
    bool nt = true;
    int j;
    for (j = 1; j <= pr; j++)
      if (i % prime[j] == 0) {
        nt = false;
        dvs[i] = j;
        if (dvs[i] == dvs[i / prime[j]])
          mu[i] = mu[i / prime[j]] * prime[j];
        else
          mu[i] = prime[j];
        break;
      }
    if (nt) {
      pr++;
      prime[pr] = i;
      dvs[i] = pr;
      mu[i] = i;
    }
  }
  int res;
  scanf("%i", &n);
  for (int i = (1); i <= (n); i++) {
    scanf("%i%i", &x, &y);
    dem = 0;
    check(x, 1);
    res = 0;
    for (int j = (1); j <= (dem); j++) {
      if (last[plist[j]] < i - y) res++;
      last[plist[j]] = i;
    }
    printf("%i\n", res);
  }
  return 0;
}
