#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1e5 + 1;
vector<int> getDivisor(int n) {
  vector<int> ret;
  for (int i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      ret.push_back(i);
      if (i != n / i) ret.push_back(n / i);
    }
  }
  return ret;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  int n;
  cin >> n;
  vector<int> lastDiv(MAXN);
  vector<int> divisor;
  int x, y, answer;
  for (int i = 1; i <= n; i++) {
    answer = 0;
    cin >> x >> y;
    divisor = getDivisor(x);
    for (int j = 0; j < divisor.size(); j++) {
      if (lastDiv[divisor[j]] < i - y) answer++;
      lastDiv[divisor[j]] = max(lastDiv[divisor[j]], i);
    }
    cout << answer << "\n";
  }
  return 0;
}
