#include <bits/stdc++.h>
using namespace std;
inline int readint() {
  char c = getchar();
  while (!isdigit(c)) c = getchar();
  int x = 0;
  while (isdigit(c)) {
    x = x * 10 + c - '0';
    c = getchar();
  }
  return x;
}
inline long long readlong() {
  char c = getchar();
  while (!isdigit(c)) c = getchar();
  long long x = 0;
  while (isdigit(c)) {
    x = x * 10 + c - '0';
    c = getchar();
  }
  return x;
}
int cx[100005], cy[100005];
vector<int> divs[100005];
int pre[100005];
int main() {
  int n;
  for (int i = (int)(1); i <= (int)(100005 - 1); i++) {
    for (int j = i; j < 100005; j += i) {
      divs[j].push_back(i);
    }
  }
  scanf("%d", &n);
  for (int i = (int)(1); i <= (int)(n); i++) scanf("%d%d", &cx[i], &cy[i]);
  for (int i = (int)(1); i <= (int)(n); i++) {
    int val = cx[i];
    int c = 0;
    for (int j = 0; j < (int)(divs[val].size()); j++) {
      if (pre[divs[val][j]] < i - cy[i]) c++;
      pre[divs[val][j]] = i;
    }
    printf("%d\n", c);
  }
  return 0;
}
