#include <bits/stdc++.h>
using namespace std;
int a[100002];
int main() {
  int n, i, j, k, x, y;
  cin >> n;
  for (i = 1; i <= n; i++) {
    cin >> x >> y;
    k = 0;
    for (j = 1; j * j <= x; j++) {
      if (x % j == 0) {
        if (a[j] < i - y) k++;
        a[j] = i;
        if (a[x / j] < i - y) k++;
        a[x / j] = i;
      }
    }
    if (j * j == x) k--;
    cout << k << endl;
  }
  return 0;
}
