#include <bits/stdc++.h>
using namespace std;
template <typename T1, typename T2>
inline std::ostream& operator<<(std::ostream& os, const std::pair<T1, T2>& p) {
  return os << "(" << p.first << ", " << p.second << ")";
}
template <typename T>
inline std::ostream& operator<<(std::ostream& os, const std::vector<T>& v) {
  bool first = true;
  os << "[";
  for (unsigned int i = 0; i < v.size(); i++) {
    if (!first) os << ", ";
    os << v[i];
    first = false;
  }
  return os << "]";
}
template <typename T>
inline std::ostream& operator<<(std::ostream& os, const std::set<T>& v) {
  bool first = true;
  os << "[";
  for (typename std::set<T>::const_iterator ii = v.begin(); ii != v.end();
       ++ii) {
    if (!first) os << ", ";
    os << *ii;
    first = false;
  }
  return os << "]";
}
template <typename T1, typename T2>
inline std::ostream& operator<<(std::ostream& os, const std::map<T1, T2>& v) {
  bool first = true;
  os << "[";
  for (typename std::map<T1, T2>::const_iterator ii = v.begin(); ii != v.end();
       ++ii) {
    if (!first) os << ", ";
    os << *ii;
    first = false;
  }
  return os << "]";
}
template <typename T>
string ToString(T Number) {
  ostringstream ss;
  ss << Number;
  return ss.str();
}
static const int MOD = (int)1e9 + 7;
int n, x, t;
int a[100001], b[100001] = {0};
void init() {
  for (int i = 0; i < n; i++) {
    a[i] = 1;
  }
}
int binpow(int a, int n) {
  int res = 1;
  while (n) {
    if (n & 1) {
      res *= a;
      res %= MOD;
    }
    a *= a;
    a %= MOD;
    n >>= 1;
  }
  return res % MOD;
}
int read(int idx) {
  int sum = 1;
  while (idx > 0) {
    sum *= a[idx];
    sum = sum % MOD;
    idx -= (idx & -idx);
  }
  return sum;
}
int readSingle(int idx) {
  int sum = a[idx];
  if (idx > 0) {
    int z = idx - (idx & -idx);
    idx--;
    while (idx != z) {
      sum /= a[idx];
      idx -= (idx & -idx);
    }
  }
  return sum;
}
void update(int idx, int val) {
  while (idx <= (n - 1)) {
    a[idx] = (a[idx] * val) % MOD;
    idx += (idx & -idx);
  }
}
int main() {
  int n, x, y;
  cin >> n;
  int ans[100005], res = 0, temp;
  for (int i = 0; i < 100005; i++) ans[i] = -1;
  for (int i = 0; i < n; i++) {
    res = 0;
    cin >> x >> y;
    for (int j = 1; j * j <= x; j++) {
      if (x % j == 0) {
        if (ans[j] < i - y) res++;
        if (j * j != x && ans[x / j] < i - y) res++;
        ans[j] = ans[x / j] = i;
      }
    }
    cout << res << endl;
  }
  return 0;
}
