#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:16777216")
#pragma warning(disable : 4786)
using namespace std;
int MIN(int a, int b) { return a < b ? a : b; }
int MAX(int a, int b) { return a > b ? a : b; }
int GCD(int a, int b) {
  while (b) b ^= a ^= b ^= a %= b;
  return a;
}
int LCM(int a, int b) { return a * (b / GCD(a, b)); }
void SWAP(int &a, int &b) {
  a = a ^ b;
  b = a ^ b;
  a = a ^ b;
}
const double PI = acos(-1);
const double ESP = 1e-11;
int arr[100100], brr[100010], crr[100010];
int main() {
  int ind, i, j, N, T, result, cnt, counter, temp, temp1, idx, index, a, b, c,
      d, e, f, g, h, n, m, k;
  memset(crr, -1, sizeof(crr));
  while (scanf("%d", &n) != EOF) {
    for (i = 0; i < n; i++) {
      counter = 0;
      scanf("%d%d", &a, &e);
      b = a;
      c = sqrt(b);
      memset(brr, NULL, sizeof(brr));
      cnt = 0;
      {
        for (j = 1; j <= c; j++) {
          f = j;
          g = b / j;
          if (b % f == 0) {
            if (crr[f] == -1 || crr[f] < i - e) {
              counter += 1;
            }
            if (f != g && (crr[g] == -1 || crr[g] < i - e)) {
              counter += 1;
            }
            crr[f] = i;
            if (b % g == 0) {
              crr[g] = i;
            }
          }
        }
        f = b;
        if (crr[f] == -1 || crr[f] < i - e) {
          crr[f] = i;
          counter += 1;
        }
        printf("%d\n", counter);
      }
    }
    memset(arr, NULL, sizeof(arr));
  }
  return 0;
}
