#include <bits/stdc++.h>
using namespace std;
vector<int> v[100010];
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < (n); ++i) {
    int x, y;
    scanf("%d%d", &x, &y);
    int p = i - y;
    int k = i - 1;
    if (p < 0) p = 0;
    int end = sqrt((double)x);
    vector<int> pom;
    for (int j = (1); j < (end); ++j)
      if (!(x % j)) {
        pom.push_back(j);
        pom.push_back(x / j);
      }
    if (!(x % end)) {
      pom.push_back(end);
      if (x / end != end) pom.push_back(x / end);
    }
    if (p > k)
      printf("%d\n", (int)pom.size());
    else {
      int res = pom.size();
      for (int j = 0; j < ((int)pom.size()); ++j) {
        int pos = lower_bound(v[pom[j]].begin(), v[pom[j]].end(), p) -
                  v[pom[j]].begin();
        if (pos < v[pom[j]].size() && v[pom[j]][pos] <= k) res--;
      }
      printf("%d\n", res);
    }
    for (int j = 0; j < ((int)pom.size()); ++j) v[pom[j]].push_back(i);
  }
  return 0;
}
