#include <bits/stdc++.h>
using namespace std;
int blocked[100001];
int n;
int main(void) {
  memset(blocked, -1, sizeof(blocked));
  cin >> n;
  for (int i = 0; i < n; i++) {
    int x, p, c = 0;
    cin >> x >> p;
    for (int z = 1; z * z <= x; z++) {
      if (x % z == 0) {
        if (blocked[z] < i - p) c++;
        if (z * z != x && blocked[x / z] < i - p) c++;
        blocked[z] = blocked[x / z] = i;
      }
    }
    cout << c << endl;
  }
}
