#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5;
int s[N];
bool query(int d, int y) { return (s[d] < y); }
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    int x, y, c = 0;
    cin >> x >> y;
    int z = sqrt(x);
    for (int j = 1; j <= z; j++) {
      if (x % j == 0) {
        c += query(j, i - y);
        s[j] = i;
        if ((j * j) != x) {
          c += query(x / j, i - y);
          s[x / j] = i;
        }
      }
    }
    cout << c << '\n';
    ;
  }
  return 0;
}
