#include <bits/stdc++.h>
using namespace std;
int isprime[100001];
int divisor[100001];
int lastseen[100000];
set<int> getFactors(int x) {
  set<int> factors;
  factors.insert(1);
  while (x > 1) {
    int d = divisor[x];
    x /= d;
    set<int> temp(factors);
    for (auto f = temp.begin(); f != temp.end(); f++) {
      factors.insert((*f) * d);
    }
  }
  return factors;
}
int main() {
  fill(isprime, isprime + 100001, -1);
  fill(divisor, divisor + 100001, -1);
  for (int i = 2; i < 100001; i++) {
    if (isprime[i] == -1) {
      isprime[i] = 1;
      divisor[i] = i;
      for (int j = i + i; j < 100001; j += i) {
        isprime[j] = 0;
        divisor[j] = i;
      }
    }
  }
  fill(lastseen, lastseen + 100000, -1);
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    int x, y;
    cin >> x >> y;
    set<int> factors = getFactors(x);
    int count = 0;
    for (auto f = factors.begin(); f != factors.end(); f++) {
      if (lastseen[*f] < i - y) {
        count++;
      }
      lastseen[*f] = i;
    }
    cout << count << endl;
  }
  return 0;
}
