Little Petya loves looking for numbers' divisors. One day Petya came across the following problem:

You are given n queries in the form "xi yi". For each query Petya should count how many divisors of number xi divide none of the numbers xi - yi, xi - yi + 1, ..., xi - 1. Help him.

Input

The first line contains an integer n (1 ≤ n ≤ 105). Each of the following n lines contain two space-separated integers xi and yi (1 ≤ xi ≤ 105, 0 ≤ yi ≤ i - 1, where i is the query's ordinal number; the numeration starts with 1). 

If yi = 0 for the query, then the answer to the query will be the number of divisors of the number xi. In this case you do not need to take the previous numbers x into consideration.

Output

For each query print the answer on a single line: the number of positive integers k such that <image>

Examples

Input

6
4 0
3 1
5 2
6 2
18 4
10000 3


Output

3
1
1
2
2
22

Note

Let's write out the divisors that give answers for the first 5 queries:

1) 1, 2, 4 

2) 3

3) 5

4) 2, 6

5) 9, 18
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Map;
import java.util.Set;

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int n = Integer.parseInt(br.readLine());
		int[] x = new int[n];
		int[] y = new int[n];
		int max = Integer.MIN_VALUE;
		for (int i = 0; i < n; i++) {
			String[] parts = br.readLine().split("\\s+");
			x[i] = Integer.parseInt(parts[0]);
			y[i] = Integer.parseInt(parts[1]);
			if (max < x[i])
				max = x[i];
		}
		int[] pos = new int[max+1];
		for(int i = 0; i < n; i++){
			Integer[]divs = divs(x[i]);
			int cnt = 0;
			for(Integer divider : divs){
				if((i+1)-y[i]<=pos[divider]){
					cnt++;
				}
				pos[divider] = i+1;
			}
			System.out.println(divs.length-cnt);
		}
	}
	
	public static Integer[] divs(int num){
		HashSet<Integer> divs = new HashSet<Integer>();
		for(int i = 1; i*i <= num; i++){
			if(num%i==0){
				divs.add(i);
				divs.add(num/i);
			}
		}
		return divs.toArray(new Integer[divs.size()]);
	}

	public static ArrayList<Integer> getDividers(int num,
			ArrayList<Integer> primes) {
		ArrayList<Integer> res = new ArrayList<Integer>();
		for (int prime : primes) {
			for (int i = prime; i <= num; i += prime) {
				if (num % i == 0) {
					res.add(i);
				} else {
					break;
				}
			}
		}
		Collections.sort(res);
		return res;
	}

	public static int GCD(int a, int b) {
		if (a < b)
			return GCD(b, a);
		if (a % b == 0)
			return b;
		return GCD(a / b, a % b);
	}

	private static void version19_47() throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int n = Integer.parseInt(br.readLine());
		int[] x = new int[n];
		int[] y = new int[n];
		HashSet<Integer> needDividers = new HashSet<Integer>();
		int max = Integer.MIN_VALUE;
		for (int i = 0; i < n; i++) {
			String[] parts = br.readLine().split("\\s+");
			x[i] = Integer.parseInt(parts[0]);
			y[i] = Integer.parseInt(parts[1]);
			if (max < x[i])
				max = x[i];
			needDividers.add(x[i]);
		}
		ArrayList<Integer> primesList = new ArrayList<Integer>();
		boolean[] notPrimes = new boolean[max + 1];
		for (int i = 2; i * i <= max; i++) {
			if (!notPrimes[i]) {
				primesList.add(i);
				for (int j = 2; j * i <= max; j++) {
					notPrimes[j * i] = true;
				}
			}
		}
		for (int i = 2; i <= max; i++) {
			if (!notPrimes[i]) {
				primesList.add(i);
			}
		}
		// System.out.println(Arrays.toString(primesList.toArray()));
		Map<Integer, HashSet<Integer>> divs = new HashMap<Integer, HashSet<Integer>>();
		for (int i = 1; i <= max; i++) {
			if (!needDividers.contains(i))
				continue;
			HashSet<Integer> dividers = divs.get(i);
			if (dividers == null) {
				dividers = new HashSet<Integer>();
			}
			dividers.add(1);
			dividers.add(i);
			if (notPrimes[i]) {
				for (Integer prime : primesList) {
					if (prime > i)
						break;
					for (int j = 1; j * prime <= i; j++) {
						if (i % (j * prime) == 0) {
							dividers.add(j * prime);
						}
					}
				}
			}
			divs.put(i, dividers);
		}
		HashMap<Integer, HashSet<Integer>> remainingDivs = new HashMap<Integer, HashSet<Integer>>();
		for (int i = 0; i < n; i++) {
			if (y[i] == 0) {
				System.out.println(divs.get(x[i]).size());
				continue;
			}
			HashSet<Integer> preparedDivs = remainingDivs.get(i - 1);
			if (preparedDivs != null && y[i - 1] == y[i] - 1) {
				Iterator<Integer> iter = divs.get(x[i]).iterator();
				int cnt = 0;
				while (iter.hasNext()) {
					Integer divider = iter.next();
					if (preparedDivs.contains(divider)) {
						cnt++;
					}
				}
				HashSet<Integer> dividesAll = (HashSet<Integer>) divs.get(x[i])
						.clone();
				dividesAll.addAll(preparedDivs);
				remainingDivs.put(i, dividesAll);
				System.out.println(divs.get(x[i]).size() - cnt);
				continue;
			}
			Iterator<Integer> iter = divs.get(x[i]).iterator();
			int cnt = 0;
			HashSet<Integer> dividesAll = (HashSet<Integer>) divs.get(x[i])
					.clone();
			while (iter.hasNext()) {
				Integer divider = iter.next();
				for (int j = i - y[i]; j < i; j++) {
					if (x[j] % divider == 0) {
						cnt++;
						dividesAll.add(divider);
						break;
					}
				}
			}
			remainingDivs.put(i, dividesAll);
			System.out.println(divs.get(x[i]).size() - cnt);
		}
	}
}
