#include <bits/stdc++.h>
using namespace std;
int n, a, b, has[100005];
vector<int> vec[100005];
void sieve() {
  for (int i = 1; i < 100001; ++i) vec[i].push_back(1);
  for (int i = 2; i < 100001; ++i)
    for (int j = i; j < 100001; j += i) vec[j].push_back(i);
}
int main() {
  sieve();
  cin >> n;
  int c = 1;
  while (n--) {
    int ans = 0;
    cin >> a >> b;
    for (int i = 0; i < (int)vec[a].size(); ++i) {
      if (has[vec[a][i]] < c - b) ans++;
      has[vec[a][i]] = c;
    }
    cout << ans << endl;
    c++;
  }
  return 0;
}
