#include <bits/stdc++.h>
using namespace std;
int seen[1000005];
int main() {
  int n, len, ans, cnt;
  int t, y;
  scanf("%d", &t);
  memset(seen, 0, sizeof(seen));
  for (int q = 1; q <= t; ++q) {
    scanf("%d %d", &n, &y);
    len = (int)(sqrt(n));
    ans = 0;
    cnt = 0;
    for (int i = 1; i <= len; ++i) {
      if (n % i == 0) {
        if (seen[i] == 0)
          ;
        else if (seen[i] >= q - y && seen[i] <= q)
          ans++;
        seen[i] = q;
        cnt++;
        if (i != n / i) {
          if (seen[n / i] == 0)
            ;
          else if (seen[n / i] >= q - y && seen[n / i] <= q)
            ans++;
          seen[n / i] = q;
          cnt++;
        }
      }
    }
    printf("%d\n", cnt - ans);
  }
  return 0;
}
