#include <bits/stdc++.h>
using namespace std;
int n, x, y, pos[100001];
vector<int> d[100001];
void sieve() {
  memset(d, 0, sizeof(d));
  for (int i = 1; i < 100001; i++)
    for (int j = i; j < 100001; j += i) d[j].push_back(i);
  memset(pos, 0, sizeof(pos));
}
int main() {
  sieve();
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d %d", &x, &y);
    if (y == 0) {
      printf("%d\n", d[x].size());
      for (int j = 0; j < d[x].size(); j++) pos[d[x][j]] = i;
      continue;
    }
    int Count = 0;
    for (int j = 0; j < d[x].size(); j++) {
      int num = d[x][j];
      if (pos[num] < i - y) Count++;
      pos[num] = i;
    }
    printf("%d\n", Count);
  }
  return 0;
}
