#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 4;
vector<int> indx[N], arr[N];
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0), cout.tie(0);
  for (int i = 1; i < N; i++) {
    int x = sqrt(i);
    for (int j = 1; j <= x; j++) {
      if (i % j == 0) {
        arr[i].push_back(j);
        if (j != i / j) arr[i].push_back(i / j);
      }
    }
  }
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    int x, y;
    cin >> x >> y;
    int c = arr[x].size();
    if (y != 0) {
      c = 0;
      for (int j = 0; j < arr[x].size(); j++) {
        int v = arr[x][j];
        if (lower_bound(indx[v].begin(), indx[v].end(), i - y) == indx[v].end())
          c++;
      }
    }
    cout << c << '\n';
    for (int j = 0; j < arr[x].size(); j++) indx[arr[x][j]].push_back(i);
  }
  return 0;
}
