#include <bits/stdc++.h>
using namespace std;
vector<int> divi[100017];
set<int> st[100017];
int main() {
  for (int i = 1; i <= 100007; i++) {
    for (int j = i; j <= 100007; j += i) {
      divi[j].push_back(i);
    }
  }
  int n;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    int x, y;
    scanf("%d%d", &x, &y);
    int c = 0;
    for (int j = 0; j < divi[x].size(); j++) {
      int up = i - y;
      if (st[divi[x][j]].lower_bound(up) == st[divi[x][j]].end()) c++;
      st[divi[x][j]].insert(i);
    }
    cout << c << endl;
  }
  return 0;
}
