#include <bits/stdc++.h>
using namespace std;
const int MAX = 500004;
long long p, pos1, pos2, q, x, l, ans = 0, r, y, z, k, n, m, t, d, c = 0,
                                  sum = 0;
long long int mn = 0x3f3f3f3f, len, cnt = 1, mx = -1000;
std::vector<int> v[MAX];
int a[105];
string s[10004], s1, s2;
map<string, string> mp;
vector<int> goal[100015];
void precomp() {
  for (int i = 1; i < 100010; i++)
    for (int j = i; j < 100010; j += i) goal[j].push_back(i);
}
int main() {
  cin >> n;
  precomp();
  int recent[100005];
  memset(recent, (0), sizeof(recent));
  for (long long int i = (1); i <= (n); i++) {
    cin >> x >> y;
    if (y == 0) {
      cout << goal[x].size() << endl;
      for (int k : goal[x]) recent[k] = i;
    } else {
      c = 0;
      for (int k : goal[x]) {
        c += (recent[k] < i - y);
        recent[k] = i;
      }
      cout << c << endl;
    }
  }
  return 0;
}
