#include <bits/stdc++.h>
using namespace std;
const int MAXN = 100005;
int last[MAXN], n, x, y, d, sol;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> x >> y;
    sol = 0;
    int j = 1;
    while (j * j <= x) {
      if (x % j == 0) {
        if (last[j] + y < i) sol++;
        last[j] = i;
        if (last[x / j] + y < i) sol++;
        last[x / j] = i;
      }
      j++;
    }
    cout << sol << endl;
  }
}
