#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f3f;
const int maxn = 100008;
const int Mod = 1e9 + 7;
vector<int> A[maxn], B[maxn];
void deal() {
  for (int i = 1; i < maxn; i++) {
    for (int j = i; j < maxn; j += i) A[j].push_back(i);
  }
}
int main() {
  int n, x, y;
  deal();
  cin >> n;
  for (int k = 1; k <= n; k++) {
    cin >> x >> y;
    if (y == 0) {
      cout << A[x].size() << endl;
      for (int i = 1; i <= A[x].size(); i++) {
        int v = A[x][i - 1];
        B[v].push_back(k);
      }
      continue;
    }
    int ans = 0;
    for (int i = 1; i <= A[x].size(); i++) {
      int v = A[x][i - 1], a = k - y, b = k - 1;
      if (B[v].size() == 0)
        ans++;
      else {
        if (upper_bound(B[v].begin(), B[v].end(), b) -
                lower_bound(B[v].begin(), B[v].end(), a) ==
            0)
          ans++;
      }
      B[v].push_back(k);
    }
    cout << ans << endl;
  }
}
