#include <bits/stdc++.h>
using namespace std;
long long ii, r, need, pl, ans, d[200000], x, y, i, j, n;
int ch(int x, int y) {
  if (x > 0 && x <= n && y > 0 && y <= n)
    return 1;
  else
    return 0;
}
int main() {
  cin >> n;
  for ((i) = (0); i < (100001); ++i) d[i] = -1;
  for ((j) = (0); j < (n); ++j) {
    cin >> x >> y;
    if (y == 0) {
      r = 2;
      d[1] = j;
      d[x] = j;
      for ((i) = (2); i < ((int)(sqrt(x)) + 1); ++i)
        if (x % i == 0) {
          r = r + 1;
          d[i] = j;
          if (x / i != i) {
            ++r;
            d[x / i] = j;
          }
        }
      cout << r << endl;
    } else {
      ans = 0;
      for ((i) = (1); i < ((int)sqrt(x) + 1); ++i) {
        if (x % i == 0) {
          if (d[i] < j - y || d[i] > j)
            ++ans;
          else if (d[i] == -1)
            ++ans;
          d[i] = j;
          ii = x / i;
          if (ii != i) {
            if (d[ii] < j - y || d[ii] > j)
              ++ans;
            else if (d[ii] == -1)
              ++ans;
            d[ii] = j;
          }
        }
      }
      cout << ans << endl;
    }
  }
}
