#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 10;
int D[N];
int main() {
  int n;
  scanf("%d", &n);
  int pos = 1;
  while (n--) {
    int x, y;
    scanf("%d%d", &x, &y);
    int sum = 0, len = sqrt(x);
    for (int i = 1; i <= len; i++) {
      if (x % i == 0) {
        if (D[i] < pos - y) sum++;
        D[i] = pos;
        if (i * i == x) continue;
        if (D[x / i] < pos - y) sum++;
        D[x / i] = pos;
      }
    }
    pos++;
    cout << sum << '\n';
  }
}
