#include <bits/stdc++.h>
using namespace std;
int n, x, y, d[100005];
vector<int> v[100005];
int main() {
  ios_base::sync_with_stdio(0);
  for (int i = 1; i <= 100000; i++)
    for (int j = i; j <= 100000; j += i) v[j].push_back(i);
  cin >> n;
  for (int k = 1; k <= n; k++) {
    cin >> x >> y;
    int ans = 0;
    for (int i = 0; i < v[x].size(); i++)
      if (d[v[x][i]] < k - y)
        ans++, d[v[x][i]] = k;
      else
        d[v[x][i]] = k;
    cout << ans << endl;
  }
  return 0;
}
