#include <bits/stdc++.h>
using namespace std;
const int me = 100025;
int N;
int x, y;
vector<int> divisors[me], occurs[me];
int main() {
  for (int i = 1; i < me; i++)
    for (int j = i; j < me; j += i) divisors[j].push_back(i);
  scanf("%d", &N);
  for (int i = 1; i <= N; i++) {
    scanf("%d%d", &x, &y);
    if (y == 0) {
      printf("%d\n", (int)divisors[x].size());
    } else {
      int bad = 0;
      for (int j : divisors[x]) {
        auto it = lower_bound(occurs[j].begin(), occurs[j].end(), i - y);
        if (it != occurs[j].end()) bad++;
      }
      printf("%d\n", (int)divisors[x].size() - bad);
    }
    for (int j : divisors[x]) occurs[j].push_back(i);
  }
  return 0;
}
