#include <bits/stdc++.h>
using namespace std;
const int INF = 1 << 29;
const double EPS = 1e-10;
const double PI = 3.1415926535897932384626433832795;
const int CLK = CLOCKS_PER_SEC;
const int sz = 350;
vector<int> nums;
int x[200000], y, n;
bool ng[400][100001];
bool ok(int num, int s, int e) {
  while (s % sz != 0 && s < e) {
    if (x[s++] % num == 0) return false;
  }
  while (e % sz != 0 && e > s) {
    if (x[--e] % num == 0) return false;
  }
  int a = s / sz;
  int b = e / sz;
  for (int i = a; i < b; i++)
    if (ng[i][num]) return false;
  return true;
}
int main() {
  int cnt = 0;
  cin >> n;
  memset(ng, false, sizeof(ng));
  for (int i = 0; i < n; i++) {
    cnt = 0;
    cin >> x[i] >> y;
    for (int j = 1; j * j <= x[i]; j++) {
      if (x[i] % j == 0) {
        int num1 = j;
        int num2 = x[i] / j;
        if (y == 0) {
          ng[i / sz][num1] = true;
          ng[i / sz][num2] = true;
          cnt += 2;
          if (num1 == num2) cnt--;
        } else {
          if (ok(num1, i - y, i)) {
            cnt++;
          }
          if (num1 != num2 && ok(num2, i - y, i)) {
            cnt++;
          }
          ng[i / sz][num1] = true;
          ng[i / sz][num2] = true;
        }
      }
    }
    cout << cnt << endl;
  }
  return 0;
}
