#include <bits/stdc++.h>
using namespace std;
template <class _T>
inline _T sqr(const _T& first) {
  return first * first;
}
const long double PI = 3.1415926535897932384626433832795;
const long double EPS = 1e-11;
int n, first, second;
int a[100100];
int main() {
  cin >> n;
  for (__typeof(n) k = 0; k < (n); k++) {
    cin >> first >> second;
    int ans = 0;
    for (int i = 1; i * i <= first; i++)
      if (first % i == 0) {
        if (second != 0) {
          if (a[i] <= k - second) ans++;
          if ((i * i != first) && (a[first / i] <= k - second)) ans++;
        } else {
          if (i * i != first) ans++;
          ans++;
        }
        a[i] = k + 1;
        a[first / i] = k + 1;
      }
    cout << ans << endl;
  }
  return 0;
}
