#include <bits/stdc++.h>
using namespace std;
long long int d[1000006];
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long int n, ans = 0, x, y;
  memset(d, -1, sizeof(d));
  cin >> n;
  for (long long int i = 1; i <= n; i++) {
    cin >> x >> y;
    ans = 0;
    for (long long int j = 1; j * j <= x; j++) {
      if (x % j != 0) continue;
      long long int k = j;
      if (d[k] < i - y) ans++;
      d[k] = i;
      if (x != j * j) {
        k = x / j;
        if (d[k] < i - y) ans++;
        d[k] = i;
      }
    }
    cout << ans << endl;
  }
}
