#include <bits/stdc++.h>
using namespace std;
int prime[100005], cnt, lcm[100005];
bool visit[100005];
int Div[100005];
int gcd(int a, int b) { return (b == 0) ? a : gcd(b, a % b); }
void GetPrime() {
  for (int i = 2; i < 100005; i++) {
    if (!visit[i]) prime[cnt++] = i;
    for (int j = 0; j < cnt && prime[j] * i < 100005; j++) {
      visit[prime[j] * i] = 1;
      if (i % prime[j] == 0) break;
    }
  }
}
int main() {
  GetPrime();
  int n, x, y;
  cin >> n;
  lcm[0] = 1;
  memset(Div, -1, sizeof(Div));
  for (int i = 0; i < n; i++) {
    cin >> x >> y;
    int ans = 0;
    for (int j = 1; j * j <= x; j++) {
      if (x % j == 0) {
        if (i - Div[j] > y) ans++;
        Div[j] = i;
        if (j * j != x) {
          if (i - Div[x / j] > y) ans++;
          Div[x / j] = i;
        }
      }
    }
    cout << ans << endl;
  }
  return 0;
}
