#include <bits/stdc++.h>
using namespace std;
const int A7MED = 0xA73ED;
int last[A7MED];
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    int x, y, cnt = 0;
    cin >> x >> y;
    for (int j = 1; j <= sqrt(x); j++) {
      if (x % j == 0) {
        if (last[j] < i - y) cnt++;
        if (j != sqrt(x) && last[x / j] < i - y) cnt++;
        last[j] = last[x / j] = i;
      }
    }
    cout << cnt << '\n';
  }
}
