#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int available[1000000];
  int aux;
  int aux2;
  for (int i = 0; i < 1000000; ++i) {
    available[i] = -2;
  }
  for (int i = 0; i < n; ++i) {
    int k = 0;
    cin >> aux;
    cin >> aux2;
    if (!(aux % 2)) {
      if ((i - available[2]) > aux2) {
        k++;
      }
      available[2] = i;
      if ((i - available[aux / 2]) > aux2) {
        k++;
      }
      available[aux / 2] = i;
    }
    for (int j = 1; j <= sqrt(aux); j++) {
      if (!(aux % j)) {
        if ((i - available[j]) > aux2) {
          k++;
        }
        available[j] = i;
        if ((i - available[aux / j]) > aux2) {
          k++;
        }
        available[aux / j] = i;
      }
    }
    printf("%d\n", k);
  }
}
