#include <bits/stdc++.h>
using namespace std;
int vis[100010];
int main() {
  int n;
  scanf("%d", &n);
  memset(vis, 0, sizeof(vis));
  for (int i = 1; i <= n; i++) {
    int x, y, cnt = 0;
    scanf("%d %d", &x, &y);
    int sq = sqrt(x);
    for (int j = 1; j <= sq; j++) {
      if (x % j == 0) {
        if (!vis[j] || i - y > vis[j]) cnt++;
        vis[j] = i;
        if (!vis[x / j] || i - y > vis[x / j]) cnt++;
        vis[x / j] = i;
      }
    }
    printf("%d\n", cnt);
  }
  return 0;
}
