#include <bits/stdc++.h>
using namespace std;
long long mas[100001], n, x, y;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  for (long long i = 0; i < 100001; i++) mas[i] = -1;
  for (long long i = 0; i < n; i++) {
    cin >> x >> y;
    long long ans = 0;
    for (int j = 1; j * j <= x; j++)
      if (x % j == 0) {
        int x1, y1;
        x1 = j, y1 = x / j;
        if (mas[x1] < i - y) ans++;
        if (mas[y1] < i - y) ans++;
        if (x1 == y1 && mas[x1] < i - y) ans--;
      }
    for (int j = 1; j * j <= x; j++)
      if (x % j == 0) mas[j] = mas[x / j] = i;
    cout << ans << endl;
  }
  return 0;
}
