#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#pragma GCC target("sse4")
const long long LL_INF = 0x3f3f3f3f3f3f3f3f;
template <typename T>
T gcd(T a, T b) {
  if (a == 0) return b;
  return gcd(b % a, a);
}
long long power(long long a, long long b, long long m = 1000000007) {
  long long answer = 1;
  while (b) {
    if (b & 1) answer = (answer * a) % m;
    b /= 2;
    a = (a * a) % m;
  }
  return answer;
}
using namespace std;
void ctrl() { cout << "Control" << endl; }
long long make_num(string p) {
  stringstream geek(p);
  long long x = 0;
  geek >> x;
  return x;
}
string make_str(long long x) {
  ostringstream str1;
  str1 << x;
  string geek = str1.str();
  return geek;
}
signed main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cin.exceptions(cin.failbit);
  long long n;
  cin >> n;
  long long used[100000 + 5];
  for (long long i = 0; i <= 100000; i++) used[i] = -1;
  for (long long i = 0; i < n; i++) {
    long long x, id;
    cin >> x >> id;
    long long cnt = 0;
    for (long long j = 1; j <= sqrt(x); j++) {
      if (x % j == 0 && i - id > used[j]) {
        cnt++;
      }
      if (x / j != j && x % j == 0) {
        long long h = x / j;
        if (i - id > used[h]) {
          cnt++;
        }
      }
    }
    for (long long j = 1; j <= sqrt(x); j++) {
      if (x % j == 0) used[j] = i;
      if (x / j != j && x % j == 0) {
        long long h = x / j;
        used[h] = i;
      }
    }
    cout << cnt << '\n';
  }
  return 0;
}
