#include <bits/stdc++.h>
using namespace std;
const double pi = acos(-1.0);
struct tt {
  int num;
  int pos;
  tt(int x, int y) {
    num = x;
    pos = y;
  }
};
int cmp(const tt& a, const tt& b) {
  if (a.num == b.num)
    return a.pos < b.pos;
  else
    return a.num < b.num;
}
vector<pair<long long, long long> > dat;
vector<tt> a;
vector<int> sol;
int n;
int main() {
  cin >> n;
  dat.resize(n);
  sol.assign(n, 0);
  for (long long i = 0; i < n; i++) {
    scanf("%d%d", &dat[i].first, &dat[i].second);
    int x = dat[i].first;
    for (int d = 1; d * d <= x; ++d)
      if (x % d == 0) {
        a.push_back(tt(d, i));
        if (d * d < x) a.push_back(tt(x / d, i));
      }
  }
  sort((a).begin(), (a).end(), cmp);
  ++sol[0];
  for (long long i = 0; i < (long long)a.size(); i++) {
    if (i == 0) continue;
    if (dat[a[i].pos].second == 0) {
      ++sol[a[i].pos];
      continue;
    }
    if ((a[i - 1].num != a[i].num) ||
        a[i].pos - dat[a[i].pos].second > a[i - 1].pos)
      ++sol[a[i].pos];
  }
  for (long long i = 0; i < n; i++) printf("%d\n", sol[i]);
}
