#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, x, y;
  map<int, int> m;
  cin >> n;
  for (int i = 1; i <= n; ++i) {
    cin >> x >> y;
    int num = 0;
    if (m.count(x) == 0 || m[x] < i - y) {
      ++num;
    }
    m[x] = i;
    for (int j = 1; j * j <= x; ++j) {
      if (x % j == 0) {
        if (m.count(j) == 0 || m[j] < i - y) {
          ++num;
        }
        if (x - j * j && (m.count(x / j) == 0 || m[x / j] < i - y)) {
          ++num;
        }
        m[j] = i;
        m[x / j] = i;
      }
    }
    cout << num << endl;
  }
}
