#include <bits/stdc++.h>
using namespace std;
int32_t main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  long long n;
  cin >> n;
  long long store[100005] = {};
  for (long long i = 1; i <= n; i++) {
    long long x, y;
    cin >> x >> y;
    y = i - y;
    long long ct = 0;
    for (long long j = 1; j * j <= x; j++) {
      if (x % j == 0) {
        if (store[j] < y) ct++;
        if (j != x / j && store[x / j] < y) ct++;
        store[j] = i;
        store[x / j] = i;
      }
    }
    cout << ct << '\n';
  }
}
