#include <bits/stdc++.h>
using namespace std;
const int INF = INT_MAX;
const long long INFL = LLONG_MAX;
const long double pi = acos(-1);
int dx[] = {1, -1, 0, 0};
int dy[] = {0, 0, 1, -1};
int lastIndexdivisibleby[1000000];
int main() {
  ios_base::sync_with_stdio(0);
  cout.precision(15);
  cout << fixed;
  cout.tie(0);
  cin.tie(0);
  int n;
  cin >> n;
  memset(lastIndexdivisibleby, 0, sizeof(lastIndexdivisibleby));
  ;
  for (int(i) = 1; (i) <= (n); (i)++) {
    int x, y, z = 0;
    cin >> x >> y;
    for (int j = 1; j <= sqrt(x); j++) {
      if (x % j == 0) {
        if (i - y > lastIndexdivisibleby[j]) z++;
        lastIndexdivisibleby[j] = i;
        if ((j * j) != x && i - y > lastIndexdivisibleby[x / j]) z++;
        lastIndexdivisibleby[x / j] = i;
      }
    }
    cout << z << '\n';
  }
  return 0;
}
