#include <bits/stdc++.h>
using namespace std;
long long gcd(long long a, long long b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
long long lcm(long long a, long long b) { return a * (b / (gcd(a, b))); }
inline int toInt(string s) {
  int v;
  istringstream sin(s);
  sin >> v;
  return v;
}
inline long long toLL(string s) {
  long long v;
  istringstream sin(s);
  sin >> v;
  return v;
}
template <class T>
inline string toString(T x) {
  ostringstream sout;
  sout << x;
  return sout.str();
}
int queries;
int seen[100000 + 1];
int main() {
  std::ios_base::sync_with_stdio(false);
  int n;
  cin >> queries;
  int idx = 1;
  int ok;
  int ans = 0;
  while (queries--) {
    cin >> n >> ok;
    ans = 0;
    int i = 1;
    for (; i * i < n; i++) {
      if (n % i == 0) {
        if (idx - seen[i] > ok) ans++;
        seen[i] = idx;
        if (idx - seen[n / i] > ok) ans++;
        seen[n / i] = idx;
      }
    }
    if (i * i == n) {
      if (idx - seen[i] > ok) ans++;
      seen[i] = idx;
    }
    idx++;
    cout << ans << "\n";
  }
}
