#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7;
inline int add(int a, int b) { return (a % mod + b % mod) % mod; }
inline int sub(int a, int b) { return (a % mod - b % mod + mod) % mod; }
inline int mul(int a, int b) { return (a % mod * b % mod) % mod; }
inline int power(int a, int b, int MOD) {
  int res = 1;
  while (b) {
    if (b & 1) {
      res *= a;
      res %= MOD;
    }
    a = a * a;
    a %= MOD;
    b >>= 1;
  }
  return res;
}
clock_t time_p = clock();
void time() {
  time_p = clock() - time_p;
  cerr << "Time elapsed : " << (long double)(time_p) / CLOCKS_PER_SEC << '\n';
}
int last[100005];
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ;
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    int x, y;
    cin >> x >> y;
    int count = 0;
    int res = 0;
    for (int j = 1; j <= sqrtl(x); j++) {
      if (x % j == 0) {
        count++;
        if (j != x / j) count++;
        if (last[j] >= i - y) ++res;
        last[j] = i;
        if (j != x / j) {
          if (last[x / j] >= i - y) ++res;
          last[x / j] = i;
        }
      }
    }
    cout << (y == 0 ? count : count - res) << '\n';
  }
  time();
  return 0;
}
