#include <bits/stdc++.h>
using namespace std;
template <typename T>
ostream& operator<<(ostream& os, vector<T>& a) {
  for (int i = 0; i < a.size(); ++i) cout << a[i] << ' ';
  return os;
}
const double EPS = 1e-9;
const double PI = 3.1415926535897;
const int N = 1e5 + 7;
int used[N];
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n;
  cin >> n;
  for (int i = 1; i <= n; ++i) {
    int x, y;
    cin >> x >> y;
    int ans = 0;
    for (int j = 1; j * j <= x; ++j) {
      if (x % j == 0) {
        if (used[j] < i - y) ans++;
        int t = x / j;
        if (t != j && used[t] < i - y) ans++;
        used[j] = i;
        used[t] = i;
      }
    }
    cout << ans << endl;
  }
  return 0;
}
