#include <bits/stdc++.h>
using namespace std;
vector<int> divi[100010];
map<int, int> m;
int main() {
  for (int i = 2; i < 100010; i++) {
    for (int j = i; j < 100010; j += i) {
      divi[j].push_back(i);
    }
  }
  int n;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    int c = 0;
    int x, y;
    scanf("%d", &x);
    scanf("%d", &y);
    for (int j = 0; j < divi[x].size(); j++) {
      int x1 = i - m[divi[x][j]];
      if (x1 > y) c++;
      m[divi[x][j]] = i;
    }
    if (y == 0) c++;
    printf("%d\n", c);
  }
}
