#include <bits/stdc++.h>
using namespace std;
const int M = 100000 + 10;
int a[M];
int main() {
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    int x, y;
    cin >> x >> y;
    if (y == 0) {
      int num = 0;
      for (int j = 1; j * j <= x; j++) {
        if (x % j == 0) {
          num++;
          a[j] = i;
          if (x / j != j) {
            num++;
            a[x / j] = i;
          }
        }
      }
      cout << num << endl;
    } else {
      int num = 0;
      for (int j = 1; j * j <= x; j++) {
        if (x % j == 0) {
          if (a[j] < i - y) {
            num++;
          }
          a[j] = i;
          if (x / j != j) {
            if (a[x / j] < i - y) {
              num++;
            }
            a[x / j] = i;
          }
        }
      }
      cout << num << endl;
    }
  }
  return 0;
}
