#include <bits/stdc++.h>
using namespace std;
void read(vector<int> &a, int n) {
  for (int i = 0; i < n; i++) cin >> a[i];
}
void read(vector<long long> &a, int n) {
  for (int i = 0; i < n; i++) cin >> a[i];
}
const int MOD = 1e9 + 7;
const int INF = (int)2e9 + 7;
const long long LINF = (long long)1e18;
const long double PI = 3.1415926535897932384626433832795;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
const int N = 1e5 + 5;
vector<int> v[N], ans[N];
vector<int> divisors[N];
void pre() {
  for (int i = 1; i < N; i++) {
    for (int j = i; j < N; j += i) {
      divisors[j].push_back(i);
    }
  }
}
void solve() {
  pre();
  int n;
  cin >> n;
  vector<pair<int, int>> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i].first >> a[i].second;
    v[a[i].first].push_back(i);
  }
  for (int i = 1; i < N; i++) {
    for (int j = i; j < N; j += i) {
      for (auto it : v[j]) {
        ans[i].push_back(it);
      }
    }
    sort(ans[i].begin(), ans[i].end());
  }
  for (int i = 0; i < n; i++) {
    int cnt = 0;
    for (auto it : divisors[a[i].first]) {
      int l = 0, r = ans[it].size() - 1, mx = n + 1;
      while (l < r) {
        int m = (l + r) / 2;
        if (ans[it][m] < i - a[i].second) {
          l = m + 1;
        } else {
          mx = min(mx, ans[it][m]);
          r = m;
        }
      }
      if (mx >= i) {
        cnt++;
      }
    }
    cout << cnt << "\n";
  }
}
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int t = 1;
  for (int tt = 1; tt <= t; tt++) {
    solve();
  }
}
