#include <bits/stdc++.h>
const double eps = (1e-10);
const double PI = acos(-1.0);
using namespace std;
int dcmp(double a, double b) {
  return fabs(a - b) <= eps ? 0 : (a > b) ? 1 : -1;
}
int getBit(int num, int idx) { return ((num >> idx) & 1) == 1; }
int setBit1(int num, int idx) { return num | (1 << idx); }
int setBit0(int num, int idx) { return num & ~(1 << idx); }
int flipBit(int num, int idx) { return num ^ (1 << idx); }
int countNumBit1(int mask) {
  int ret = 0;
  while (mask) {
    mask &= (mask - 1);
    ++ret;
  }
  return ret;
}
int pre[100000];
int main() {
  int n;
  cin >> n;
  memset(pre, -1, sizeof(pre));
  for (int i = 0; i < n; i++) {
    int x, y;
    cin >> x >> y;
    int j, ans = 0;
    for (j = 1; j * j < x; j++) {
      if (x % j == 0) {
        if (pre[j] < i - y) ans++;
        if (pre[x / j] < i - y) ans++;
        pre[j] = i;
        pre[x / j] = i;
      }
    }
    if (x == j * j) {
      if (pre[j] < i - y) ans++;
      pre[j] = i;
    }
    cout << ans << endl;
  }
}
