#include <bits/stdc++.h>
using namespace std;
template <class T>
void BIN(T n) {
  if (!n) {
    printf("\n");
    return;
  }
  BIN(n / 2);
  cout << (n % 2);
}
vector<int> dv[100005 + 2];
int vis[100005 + 5];
int main() {
  int i, j, k, x, y, n;
  for (i = 1; i <= 100000; i++) {
    for (j = i; j <= 100000; j += i) {
      dv[j].push_back(i);
    }
  }
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d%d", &x, &y);
    int cnt = 0, sz = (int)(dv[x].size());
    for (j = 0; j < sz; j++) {
      int xx = dv[x][j];
      if (vis[xx] < (i - y)) cnt++;
      vis[xx] = i;
    }
    if (y == 0) cnt = sz;
    printf("%d\n", cnt);
  }
  return 0;
}
