#include <bits/stdc++.h>
int primes[100000];
long long limit[100000];
int cnt;
char flag[100000];
int size[10][2];
int N;
int len[100000 + 1];
void init() {
  memset(flag, 0, sizeof(flag));
  cnt = 0;
  int i, j;
  for (i = 2; i < 100000; i++) {
    if (!flag[i]) {
      limit[cnt] = i;
      limit[cnt] *= limit[cnt];
      --limit[cnt];
      primes[cnt++] = i;
      if (100000 / i + 1 > i) {
        j = i * i;
        while (j < 100000) {
          flag[j] = 1;
          j += i;
        }
      }
    }
  }
}
int search(int deep, int cur, int p, int l) {
  int ret = 0;
  if (!deep) {
    ret += len[cur] < p;
    len[cur] = l;
  } else {
    --deep;
    int i;
    ret += search(deep, cur, p, l);
    for (i = 1; i < size[deep][1]; i++) {
      cur *= size[deep][0];
      ret += search(deep, cur, p, l);
    }
  }
  return ret;
}
int main() {
  init();
  while (scanf("%d", &N) == 1) {
    int i, j;
    memset(len, 255, sizeof(len));
    for (i = 0; i < N; i++) {
      int cur, l;
      scanf("%d %d", &cur, &l);
      int tot = 0;
      for (j = 0; j < cnt && cur > limit[j]; j++) {
        if (!(cur % primes[j])) {
          size[tot][0] = primes[j];
          size[tot][1] = 1;
          do {
            ++size[tot][1];
            cur /= primes[j];
          } while (!(cur % primes[j]));
          ++tot;
        }
      }
      if (cur != 1) {
        size[tot][0] = cur;
        size[tot][1] = 2;
        ++tot;
      }
      int ans = search(tot, 1, i - l, i);
      printf("%d\n", ans);
    }
  }
  return 0;
}
