#include <bits/stdc++.h>
using namespace std;
pair<long long, long long> a[100010];
map<long long, long long> mm;
long long func(long long x, long long t, long long k) {
  long long cnt = 0;
  for (long long i = 1; i * i <= x; i++) {
    if (x % i == 0) {
      if (x / i == i) {
        if (mm[i] == 0 or mm[i] < t) {
          cnt++;
        }
        mm[i] = k;
      } else {
        if (mm[i] == 0 or mm[i] < t) {
          cnt++;
        }
        mm[i] = k;
        if (mm[x / i] == 0 or mm[x / i] < t) {
          cnt++;
        }
        mm[x / i] = k;
      }
    }
  }
  return cnt;
}
int main() {
  long long n;
  scanf("%lld", &n);
  for (long long i = 1; i <= n; ++i) {
    scanf("%lld", &a[i].first), scanf("%lld", &a[i].second);
    long long ans = func(a[i].first, i - a[i].second, i);
    printf("%lld\n", ans);
  }
}
