#include <bits/stdc++.h>
using namespace std;
int n, r;
int mii[100005];
int main() {
  cout << setprecision(9);
  int cases;
  cin >> cases;
  memset(mii, -1, sizeof(mii));
  for (int j = 0; j < cases; j++) {
    cin >> n >> r;
    int c = 0;
    for (int i = 1; i * i <= n; i++) {
      if (n % i) continue;
      int f1 = i;
      if (mii[f1] == -1)
        c++;
      else if (mii[f1] >= j - r && mii[f1] <= j - 1) {
      } else
        c++;
      mii[f1] = j;
      if (f1 * f1 != n) {
        int f2 = n / f1;
        if (mii[f2] == -1)
          c++;
        else if (mii[f2] >= j - r && mii[f2] <= j - 1) {
        } else
          c++;
        mii[f2] = j;
      }
    }
    cout << c << endl;
  }
  return 0;
}
