#include <bits/stdc++.h>
using namespace std;
double PI = 3.141592653589793;
const double EPS = 1e-9;
const int N = 1e6 + 5;
const long long mod = 1e9 + 7;
const int oo = 1e9;
int dx[] = {0, 0, 1, -1, 1, -1, 1, -1};
int dy[] = {1, -1, 0, 0, -1, 1, 1, -1};
int n;
int t[100005];
inline bool valid(int x, int idx) { return t[x] < idx; }
int main() {
  scanf("%d", &n);
  for (int j = 1; j <= n; j++) {
    int x, y;
    scanf("%d%d", &x, &y);
    int ans = 0;
    if (y == 0) {
      for (int i = 2; i * i <= x; i++) {
        if (x % i == 0) {
          ans++;
          t[i] = j;
          if (x / i != i) {
            ans++;
            t[x / i] = j;
          }
        }
      }
      ans += 2;
      t[x] = j;
    } else if (x != 1) {
      for (int i = 2; i * i <= x; i++) {
        if (x % i == 0) {
          ans += valid(i, j - y);
          t[i] = j;
          if (x / i != i) {
            ans += valid(x / i, j - y);
            t[x / i] = j;
          }
        }
      }
      ans += valid(x, j - y);
      t[x] = j;
    }
    printf("%d\n", ans);
  }
}
