#include <bits/stdc++.h>
using namespace std;
const int M = 100010;
int pn, f[M], p[M];
void init() {
  pn = 0;
  for (int i = 2; i < M; i++) {
    if (!f[i]) f[i] = i, p[pn++] = i;
    for (int j = 0; p[j] * i < M; j++) {
      f[p[j] * i] = p[j];
      if (i % p[j] == 0) break;
    }
  }
}
void factorize1(int n, int a[], int b[], int &m) {
  for (m = 0; n > 1; m++) {
    a[m] = f[n], b[m] = 0;
    while (n % a[m] == 0) n /= a[m], b[m]++;
  }
}
void find_divisors(int a[], int b[], int m, int d[], int &dn) {
  dn = 0;
  d[dn++] = 1;
  for (int i = 0; i < m; i++) {
    for (int j = 0, z = dn; j < b[i] * z; j++, dn++) d[dn] = d[dn - z] * a[i];
  }
  sort(d, d + dn);
}
int n;
int a[55], b[55], m;
int d[1000], dn;
int vt[M];
int main() {
  init();
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    int x, y;
    scanf("%d %d", &x, &y);
    factorize1(x, a, b, m);
    find_divisors(a, b, m, d, dn);
    int ans = 0;
    if (y) {
      for (int j = 0; j < dn; j++)
        if (vt[d[j]] < i - y) ans++;
    } else {
      ans = dn;
    }
    printf("%d\n", ans);
    for (int j = 0; j < dn; j++) vt[d[j]] = i;
  }
  return 0;
}
