#include <bits/stdc++.h>
using namespace std;
const int MX = 100000;
vector<int> divisors[MX + 10];
int n, last[MX + 10], pos, X;
int main() {
  for (int j = 1; j <= MX; j++)
    for (int i = j; i <= MX; i += j) divisors[i].push_back(j);
  cin >> n;
  for (int j = 1; j <= n; j++) {
    cin >> X >> pos;
    pos = j - pos;
    int sz = divisors[X].size(), ret = 0, div;
    for (int i = 0; i < sz; i++) {
      div = divisors[X][i];
      if (last[div] < pos) ret++;
      last[div] = j;
    }
    cout << ret << endl;
  }
}
