#include <bits/stdc++.h>
using namespace std;
const int N = 1e5;
vector<int> divs[N + 1];
int last_seen[N + 1];
int answer[N + 1];
struct Query {
  int x, y, idx;
  bool operator<(const Query q) const { return idx - y < q.idx - q.y; }
} queries[N + 1];
int main() {
  for (int i = 1; i <= N; i++) {
    for (int j = 1; j * j <= i; j++) {
      if (i % j == 0) {
        divs[i].push_back(j);
        if (j * j != i) divs[i].push_back(i / j);
      }
    }
  }
  priority_queue<Query> q;
  int n;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d%d", &(queries[i].x), &(queries[i].y));
    queries[i].idx = i;
  }
  for (int i = n; i >= 1; i--) {
    q.push(queries[i]);
    for (int div : divs[queries[i].x]) last_seen[div] = i;
    while (!q.empty() && q.top().idx - q.top().y == i) {
      Query query = q.top();
      q.pop();
      answer[query.idx] = divs[query.x].size();
      for (int div : divs[query.x])
        if (last_seen[div] < query.idx) --answer[query.idx];
    }
  }
  for (int i = 1; i <= n; i++) printf("%d\n", answer[i]);
  return 0;
}
