#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:1024000000,1024000000")
using namespace std;
const int N = 1100009;
const int inf = 0x3f3f3f3f;
const long long oo = 0x3f3f3f3f3f3f3f3fll;
int n;
int pre[N];
int main() {
  scanf("%d", &n);
  memset(pre, -1, sizeof(pre));
  for (int k = 0; k < n; k++) {
    int x, y;
    scanf("%d%d", &x, &y);
    int ans = 0;
    for (int i = 1; i * i <= x; i++) {
      if (x % i) continue;
      if (pre[i] == -1 || pre[i] < k - y) ans++;
      pre[i] = k;
      if (i * i == x) break;
      if (pre[x / i] == -1 || pre[x / i] < k - y) ans++;
      pre[x / i] = k;
    }
    cout << ans << endl;
  }
  return 0;
}
