#include <bits/stdc++.h>
using namespace std;
const long double EPS = 1E-9;
const int INF = (int)1E9;
const long long INF64 = (long long)1E18;
const long double PI = 2 * acos(.0);
int gr[100005];
vector<int> pp;
void divi(int n) {
  pp.clear();
  if (n == 1) return;
  pp.push_back(n);
  int i = 0;
  for (i = 2; i * i < n; i++) {
    if (n % i == 0) pp.push_back(i), pp.push_back(n / i);
  }
  if (i * i == n) pp.push_back(i);
  return;
}
int main() {
  ios_base::sync_with_stdio(0);
  memset(gr, 0, sizeof(gr));
  int n, x, y;
  cin >> n;
  for (int i = 1; i < (int)(n + 1); i++) {
    cin >> x >> y;
    divi(x);
    if (y == 0) {
      cout << (pp).size() + 1 << endl;
    } else {
      int cont = 0;
      for (int j = 0; j < (int)((pp).size()); j++) {
        if (gr[pp[j]] == 0)
          cont++;
        else if (i - y > gr[pp[j]])
          cont++;
      }
      cout << cont << endl;
    }
    for (int j = 0; j < (int)((pp).size()); j++) {
      gr[pp[j]] = i;
    }
  }
  return 0;
}
