#include <bits/stdc++.h>
const int maxn = 100000;
int last[maxn];
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    int x, y;
    scanf("%d%d", &x, &y);
    int cnt = 0;
    for (int d = 1; d * d <= x; d++)
      if (x % d == 0) {
        if (last[d] < i - y) cnt++;
        last[d] = i;
        if (d * d != x) {
          int d1 = x / d;
          if (last[d1] < i - y) cnt++;
          last[d1] = i;
        }
      }
    printf("%d\n", cnt);
  }
}
