#include <bits/stdc++.h>
using namespace std;
int divisors[100010];
int main() {
  int q;
  cin >> q;
  for (int i = 1; i <= q; i++) {
    int n, up;
    cin >> n >> up;
    long long int cnt = 0;
    for (int j = 1; j * j <= n; j++) {
      if (j * j == n) {
        if (up == 0)
          cnt++;
        else if (divisors[j] < i - up) {
          cnt++;
        }
        divisors[j] = i;
        continue;
      }
      if (n % j == 0) {
        int baal = n / j;
        if (up == 0)
          cnt += 2;
        else {
          if (divisors[j] < i - up) cnt++;
          if (divisors[baal] < i - up) cnt++;
        }
        divisors[j] = i;
        divisors[baal] = i;
      }
    }
    cout << cnt << endl;
  }
}
