#include <bits/stdc++.h>
using namespace std;
template <class T>
void debug(const T& e) {
  cout << e << endl;
}
template <class T1, class T2>
void debug(const T1& e1, const T2& e2) {
  cout << e1 << "  " << e2 << endl;
}
template <class T1, class T2, class T3>
void debug(const T1& e1, const T2& e2, const T3& e3) {
  cout << e1 << "  " << e2 << "  " << e3 << endl;
}
template <class T1, class T2, class T3, class T4>
void debug(const T1& e1, const T2& e2, const T3& e3, const T4& e4) {
  cout << e1 << "  " << e2 << "  " << e3 << "  " << e4 << endl;
}
template <class T1, class T2, class T3, class T4, class T5>
void debug(const T1& e1, const T2& e2, const T3& e3, const T4& e4,
           const T5& e5) {
  cout << e1 << "  " << e2 << "  " << e3 << "  " << e4 << "  " << e5 << endl;
}
template <class T>
void debug(vector<T>& e) {
  int i;
  for (i = 0; i < (int)e.size(); i++) cout << e[i] << " ";
  cout << endl;
}
template <class T>
void debug(vector<basic_string<T> >& e) {
  int i, j;
  for (i = 0; i < (int)e.size(); i++) {
    for (j = 0; j < (int)e[i].size(); j++) cout << e[i][j];
    cout << endl;
  }
  cout << endl;
}
long long Pow(long long B, long long P) {
  long long R = 1;
  while (P > 0) {
    if (P % 2 == 1) R = (R * B);
    P /= 2;
    B = (B * B);
  }
  return R;
}
struct pq {
  int cost, node;
  bool operator<(const pq& b) const { return cost > b.cost; }
};
bool comp(pq a, pq b) { return a.cost > b.cost; }
int c;
int T[1000001];
int main() {
  int n, i, j, x, y;
  cin >> n;
  for (i = 1; i <= n; i++) {
    cin >> x >> y;
    c = 0;
    for (j = 1; (j * j) <= x; j++) {
      if (x % j == 0) {
        if (T[j] < i - y) c++;
        if (T[x / j] < i - y && (x / j) != j) c++;
        T[j] = i;
        T[x / j] = i;
      }
    }
    cout << c << endl;
  }
  return 0;
}
