#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:64777216")
using namespace std;
template <class T>
inline T sqr(T x) {
  return x * x;
}
const double pi = acos(-1.0), eps = 1e-18;
const int INF = 1000 * 1000 * 1000, MAXN = 100005, MOD = INF + 7;
int n, x, y, num = 1, used[MAXN], cnt = 0, cur_num = 0;
void prepare(string s) {
  if ((int)s.size() != 0) {
    freopen((s + ".in").c_str(), "r", stdin);
    freopen((s + ".out").c_str(), "w", stdout);
  }
}
void solve() {
  cin >> n;
  while (n) {
    --n;
    cur_num++;
    cin >> x >> y;
    cnt = 0;
    if (y == 0) {
      set<int> denoms;
      for (int i = 1; i * i <= x; i++) {
        if (x % i == 0) {
          denoms.insert(i);
          denoms.insert(x / i);
          used[i] = used[x / i] = cur_num;
        }
      }
      cout << (int)denoms.size() << '\n';
    } else {
      set<int> denoms;
      for (int i = 1; i * i <= x; i++) {
        if (x % i == 0) {
          denoms.insert(i);
          denoms.insert(x / i);
        }
      }
      for (set<int>::iterator it = denoms.begin(); it != denoms.end(); ++it) {
        if (used[*it] < cur_num - y) cnt++;
        used[*it] = cur_num;
      }
      cout << cnt << '\n';
    }
  }
}
int main() {
  prepare("");
  solve();
  return 0;
}
