#include <bits/stdc++.h>
using namespace std;
const int MAXN = 100001;
int spf[MAXN];
int gcd(int x, int y) { return y ? gcd(y, x % y) : x; }
void precal() {
  spf[1] = 1;
  for (int i = 2; i < MAXN; i++) spf[i] = i;
  for (int i = 4; i < MAXN; i += 2) spf[i] = 2;
  for (int i = 3; i * i < MAXN; i++) {
    if (spf[i] == i)
      for (int j = i * i; j < MAXN; j += i)
        if (spf[j] == j) spf[j] = i;
  }
}
vector<int> getFactorization(int x) {
  vector<int> ret;
  while (x != 1) {
    ret.push_back(spf[x]);
    x = x / spf[x];
  }
  return ret;
}
long long exp(long long n, long long m) {
  long long a = 1;
  while (m) {
    if (m & 1) a = (a * n % 1000000007) % 1000000007;
    m /= 2;
    n = (n * n) % 1000000007;
  }
  return a;
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long t = 1, x, y;
  cin >> t;
  vector<int> last(100005 + 5, -1);
  for (int j = 0; j < t; j++) {
    cin >> x >> y;
    int ans = 0;
    for (int i = 1; i * i <= x; i++) {
      if (x % i != 0) continue;
      if (last[i] < j - y) ans++;
      last[i] = j;
      if (x / i != i && last[x / i] < j - y) ans++;
      last[x / i] = j;
    }
    cout << ans << "\n";
  }
  return 0;
}
