#include <bits/stdc++.h>
using namespace std;
int n, x, y, ans, used[111111];
int main() {
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> x >> y;
    ans = 0;
    for (int j = 1; j * j <= x; j++) {
      if (x % j == 0) {
        if (y == 0 || used[j] < i - y) ans++;
      }
      if (x % j == 0 && x / j != j) {
        if (y == 0 || used[x / j] < i - y) ans++;
      }
    }
    for (int j = 1; j * j <= x; j++)
      if (x % j == 0) used[j] = i, used[x / j] = i;
    cout << ans << endl;
  }
}
