#include <bits/stdc++.h>
using namespace std;
const long long INF = 1e18;
const long long SIZE = 1e5 + 5;
const long long mod = 1e9 + 7;
long long dp[SIZE];
int main() {
  long long t = 0, n, x, y, z, i, j, k, g, p, q, ans = 0, sum = 0, c = 0;
  scanf("%lld", &n);
  for (i = 1; i <= n; i++) {
    scanf("%lld %lld", &x, &y);
    z = i - y;
    ans = 0;
    vector<long long> div;
    for (k = 1; k * k <= x; k++) {
      if (x % k == 0) {
        j = x / k;
        if (k == j)
          div.push_back(k);
        else {
          div.push_back(k);
          div.push_back(j);
        }
      }
    }
    for (j = 0; j < div.size(); j++) {
      if (dp[div[j]] < z) ans++;
      dp[div[j]] = i;
    }
    printf("%lld\n", ans);
  }
  return 0;
}
