#include <bits/stdc++.h>
#pragma GCC optimize("O3")
using namespace std;
long long n, a, b;
vector<int> d[100002];
vector<int> wh[100002];
void ciur() {
  for (int i = 1; i <= 100000; ++i)
    for (int j = i; j <= 100000; j += i) d[j].push_back(i);
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  cin >> n;
  ciur();
  for (int i = 1; i <= n; ++i) {
    cin >> a >> b;
    if (b == 0)
      cout << d[a].size() << '\n';
    else {
      int sol = 0;
      for (int j = 0; j < d[a].size(); ++j) {
        if (wh[d[a][j]].empty()) {
          ++sol;
          continue;
        } else if (wh[d[a][j]].back() < i - b)
          ++sol;
      }
      cout << sol << '\n';
    }
    for (int j = 0; j < d[a].size(); ++j) wh[d[a][j]].push_back(i);
  }
  return 0;
}
