#include <bits/stdc++.h>
using namespace std;
const int mn = 100010;
int q[mn], p[mn], x[mn], ed[mn];
int a[mn][2];
int l, m, y, ans, now;
void dfs(int p, int x) {
  if (p > m) {
    ans += ed[x] < y;
    ed[x] = now;
    return;
  }
  if (a[p][1]) {
    --a[p][1];
    dfs(p, x * a[p][0]);
    ++a[p][1];
  }
  dfs(p + 1, x);
}
int main() {
  for (int i = 2; i <= mn - 1; ++i) {
    if (!q[i]) p[++l] = i, q[i] = i;
    for (int j = 1; j <= l; ++j) {
      if ((long long)i * p[j] > mn - 1) break;
      q[i * p[j]] = p[j];
      if (!(i % p[j])) break;
    }
  }
  int n;
  cin >> n;
  for (int i = 1; i <= n; ++i) {
    now = i;
    cin >> x[i] >> y;
    y = i - y, m = 0;
    if (y <= 0) y = 1;
    int t = x[i];
    while (t > 1) {
      int T = q[t];
      a[++m][0] = T, a[m][1] = 0;
      while (q[t] == T) t /= T, ++a[m][1];
    }
    ans = 0;
    dfs(1, 1);
    cout << ans << endl;
  }
}
