#include <bits/stdc++.h>
using namespace std;
const int NMAX = 1e5 + 2;
int n, last[NMAX], x, y;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> n;
  for (int query = 1; query <= n; query++) {
    cin >> x >> y;
    int ans = 0, autre;
    for (int d = 1; d * d <= x; d++) {
      if (x % d == 0) {
        autre = x / d;
        if (last[d] < query - y || y == 0) {
          ans++;
        }
        if ((last[autre] < query - y || y == 0) && autre != d) {
          ans++;
        }
        last[d] = last[autre] = query;
      }
    }
    cout << ans << '\n';
  }
}
