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 static java.lang.Math.*;
import static java.lang.System.currentTimeMillis;
import static java.lang.System.exit;
import static java.lang.System.arraycopy;
import static java.util.Arrays.sort;
import static java.util.Arrays.binarySearch;
import static java.util.Arrays.fill;
import java.util.*;
import java.io.*;

public class Main {

	public static void main(String[] args) throws IOException {
		try {
			if (new File("input.txt").exists())
				System.setIn(new FileInputStream("input.txt"));
		} catch (SecurityException e) {
		}
		new Thread(null, new Runnable() {
			public void run() {
				try {
					new Main().run();
				} catch (Throwable e) {
					e.printStackTrace();
					exit(999);
				}
			}
		}, "1", 1 << 23).start();
	}

	BufferedReader in;
	PrintWriter out;
	StringTokenizer st = new StringTokenizer("");

	
	
	int n, sn;
	
	int x[], y[];
	
	HashSet<Integer>[] hs;
	int MAXN = 100010;
	
	private void run() throws IOException {
		in = new BufferedReader(new InputStreamReader(System.in));
		out = new PrintWriter(System.out);

		n = nextInt();
		
		x = new int[n];
		y = new int[n];
		sn = (int)sqrt(n) + 5;
		
		hs = new HashSet[sn + 1];
		for(int i = 0; i <= sn; i++)
			hs[i] = new HashSet<Integer>(1000);
		
		
		for(int i = 0; i < n; i++){
			x[i] = nextInt();
			y[i] = nextInt();
			
			int curSet = i / sn;
			int ans = 0;
			
			for(int j = 1; j * j <= x[i]; j++)
				if(x[i] % j == 0){
					if(test(j, curSet, i - y[i], i))
						ans ++;
					
					if(j * j != x[i] &&  test(x[i] / j, curSet, i - y[i], i))
						ans ++;
					hs[curSet].add(j);
					hs[curSet].add(x[i] / j);
				}
			out.println(ans);
		}
		
		
		
		in.close();
		out.close();
	}
	
	boolean test(int elem, int curSet, int left, int num){
		int i = curSet;
		for(; i * sn >= left; i-- )
			if(hs[i].contains(elem))
				return false;
		if(i == -1)
			return true;
		for(int j = min( num - 1, (i + 1) * sn); j >= left; j--)
			if(x[j] % elem == 0)
				return false;
		return true;
	}
	
	/*
	class RSQ{
		int m[];
		int c;
		RSQ(int size){
			c = size;
			m = new int[c << 1];
		}
		void set(int ind){
			ind += c;
			m[ind] = 1;
			for(int p = ind >> 1; p != 0; p >>= 1)
				m[p] = m[p << 1] + m[1 + (p << 1)];
		}
		int get(int left, int right){
			left += c;
			right += c;
			int ans = 0;
			while(left <= right){
				if((left & 1) == 1)
					ans += m[left];
				if((right & 1) == 0)
					ans += m[right];
				left = (left + 1) >> 1;
				right = (right - 1) >> 1;
			}
			return ans;
		}
	}
	
	*/
	String nextToken() throws IOException {
		while (!st.hasMoreTokens())
			st = new StringTokenizer(in.readLine());
		return st.nextToken();
	}
	int nextInt() throws IOException {
		return Integer.parseInt(nextToken());
	}
	long nextLong() throws IOException {
		return Long.parseLong(nextToken());
	}
	double nextDouble() throws IOException {
		return Double.parseDouble(nextToken());
	}
	String nextLine() throws IOException {
		st = new StringTokenizer("");
		return in.readLine();
	}
	boolean EOF() throws IOException {
		while (!st.hasMoreTokens()) {
			String s = in.readLine();
			if (s == null)
				return true;
			st = new StringTokenizer(s);
		}
		return false;
	}
}
