#include <bits/stdc++.h>
using namespace std;
int pos[100005];
int main() {
  int n;
  scanf("%d", &n);
  memset(pos, -1, sizeof(pos));
  for (int i = 1; i <= n; i++) {
    int x, y, ans = 0;
    scanf("%d %d", &x, &y);
    for (int j = 1; j * j <= x; j++) {
      if (x % j == 0) {
        if (pos[j] == -1 || pos[j] < i - y) ans++;
        if (j != x / j && (pos[x / j] == -1 || pos[x / j] < i - y)) ans++;
        pos[j] = pos[x / j] = i;
      }
    }
    cout << ans << endl;
  }
  return 0;
}
