#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;
int last[100010];
int main() {
  int n, x, y;
  cin >> n;
  memset(last, -1, sizeof(last));
  for (int i = 1; i <= n; i++) {
    int cnt = 0;
    cin >> x >> y;
    int pos = i - y;
    for (int j = 1; j * j <= x; j++) {
      if (x % j == 0) {
        if (last[j] < pos) {
          cnt++;
        }
        last[j] = i;
        if (last[x / j] < pos) {
          cnt++;
        }
        last[x / j] = i;
      }
    }
    cout << cnt << endl;
  }
  return 0;
}
