#include <bits/stdc++.h>
using namespace std;
vector<pair<int, int> > e[100005];
bool cmp(const pair<int, int> &a, const pair<int, int> &b) {
  return a.first < b.first;
}
int main() {
  int n, x, y;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d %d", &x, &y);
    int cnt = 0;
    int d = 0;
    for (int j = 1; j * j <= x; j++) {
      if (x % j) continue;
      if (lower_bound(e[j].begin(), e[j].end(), make_pair(i - y, -1), cmp) ==
          e[j].end())
        cnt++;
      if (j * j != x &&
          lower_bound(e[x / j].begin(), e[x / j].end(), make_pair(i - y, -1),
                      cmp) == e[x / j].end())
        cnt++;
      e[j].push_back(make_pair(i, -1));
      if (j * j != x) e[x / j].push_back(make_pair(i, -1));
      d += 2;
      if (j * j == x) d--;
    }
    if (!y) cnt = d;
    printf("%d\n", cnt);
  }
}
