#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  vector<int> a(100001, 0);
  scanf("%d", &n);
  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 && i - a[j] > y) {
        ans++;
      }
      if (x % j == 0 && x % (x / j) == 0 && j * j != x && i - a[x / j] > y) {
        ans++;
      }
      if (x % j == 0) {
        a[j] = i;
        a[x / j] = i;
      };
    }
    printf("%d\n", ans);
  }
  return 0;
}
