#include <bits/stdc++.h>
using namespace std;
const int MAXN = 100005;
int mark[MAXN] = {0};
int m[MAXN] = {0};
int gen_primes(int maxn) {
  for (int p = 2; p < maxn; p++)
    if (!mark[p]) {
      mark[p] = p;
      long long int t = p;
      t *= p;
      for (; t < maxn; t += p) mark[t] = p;
    }
  return 0;
}
vector<pair<int, int> > fact(int x) {
  vector<pair<int, int> > f;
  while (x > 1) {
    int k = 0;
    int p = mark[x];
    while (x % p == 0) {
      x /= p;
      k++;
    }
    if (k) f.push_back(make_pair(p, k));
  }
  return f;
}
vector<int> divs(int x) {
  vector<pair<int, int> > f = fact(x);
  vector<int> d(1, 1);
  for (int i = 0; i < f.size(); i++) {
    int p = f[i].first;
    int k = f[i].second;
    int size = d.size();
    int t = 1;
    for (int ki = 1; ki < k + 1; ki++) {
      t *= p;
      for (int i = 0; i < size; i++) {
        int nw = d[i] * t;
        d.push_back(nw);
      }
    }
  }
  return d;
}
int main() {
  gen_primes(MAXN);
  int n;
  cin >> n;
  for (int i = 1; i < n + 1; i++) {
    int x, y;
    cin >> x >> y;
    vector<int> d = divs(x);
    if (y == 0) {
      cout << d.size() << endl;
    } else {
      int ans = 0;
      for (int j = 0; j < d.size(); j++) {
        int dj = d[j];
        int index = m[dj];
        if (index < i - y) ans++;
      }
      cout << ans << endl;
    }
    for (int j = 0; j < d.size(); j++) m[d[j]] = i;
  }
  return 0;
}
