Problem: Two soldiers are playing a game. At the beginning first of them chooses a positive integer n and gives it to the second soldier. Then the second one tries to make maximum possible number of rounds. Each round consists of choosing a positive integer x > 1, such that n is divisible by x and replacing n with n / x. When n becomes equal to 1 and there is no more possible valid moves the game is over and the score of the second soldier is equal to the number of rounds he performed.

To make the game more interesting, first soldier chooses n of form a! / b! for some positive integer a and b (a ≥ b). Here by k! we denote the factorial of k that is defined as a product of all positive integers not large than k.

What is the maximum possible score of the second soldier?

Input

First line of input consists of single integer t (1 ≤ t ≤ 1 000 000) denoting number of games soldiers play.

Then follow t lines, each contains pair of integers a and b (1 ≤ b ≤ a ≤ 5 000 000) defining the value of n for a game.

Output

For each game output a maximum score that the second soldier can get.

Examples

Input

2
3 1
6 3


Output

2
5

Solution (in JAVA):

Solution:
import java.util.*;
import java.math.*;
import java.io.*;

public class cf546 {
	static Scanner I=new Scanner(System.in);
	static BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
	static PrintWriter out = new PrintWriter(System.out);
	public static void p1() {
		int k=I.nextInt();
		int n=I.nextInt();
		int w=I.nextInt();
		int price=k*(1+w)*w/2;
		int re=Math.max(0,price-n);
		System.out.println(re);
	}
	public static void p2() {
		int n=I.nextInt();
		int []A=new int[n];
		for(int i=0; i<n; i++) {
			A[i]=I.nextInt();
		}
		Arrays.sort(A);
		int coin=0;
		for(int i=1; i<n; i++) {
			if(A[i]<=A[i-1]) {
				coin+=A[i-1]+1-A[i];
				A[i]=A[i-1]+1;
			}
		}
		System.out.println(coin);
	}
	public static int fac(int n) {
		int re=1;
		for(int i=1; i<=n; i++) {
			re*=i;
		}
		return re;
	}
	public static void p3() {
		int n=I.nextInt();
		int k1=I.nextInt();
		List l1=new ArrayList();
		for(int i=0; i<k1; i++) {
			l1.add(I.nextInt());
		}
		int k2=I.nextInt();
		List l2=new ArrayList();
		for(int i=0; i<k2; i++) {
			l2.add(I.nextInt());
		}
		int fight=0;
		int limit=fac(n);
		while(!l1.isEmpty() && !l2.isEmpty()) {
			int A=(int)l1.remove(0);
			int B=(int)l2.remove(0);
			if(A>B) {
				l1.add(B); l1.add(A);
			}else {
				l2.add(A); l2.add(B);
			}
			fight++;
			if(fight==limit) break;
		}
		if(l1.isEmpty()) System.out.printf("%d %d%n",fight,2);
		else if(l2.isEmpty()) System.out.printf("%d %d%n",fight,1);
		else System.out.println(-1);

	}
	public static void p4() throws Exception{
		int T=Integer.parseInt(in.readLine());
		int Max=5000000+1;
		int []pri=new int[Max];
		for(int i=2; i<Max; i++) {
			if(pri[i]==0) {
				for(int p=1; Math.pow(i,p)<Max; p++) {
					int val=(int)Math.pow(i,p);
					for(int j=val; j<Max; j+=val) {
						pri[j]+=1;
					}
				}
			}
		}
		for(int i=3; i<Max; i++) {
			pri[i]=pri[i-1]+pri[i];
		}
		long start=System.currentTimeMillis();
		long end=System.currentTimeMillis();
		//System.out.println(end-start);
		for(int t=0; t<T; t++) {
			String temp[]=in.readLine().split(" ");
			int a=Integer.parseInt(temp[0]);
			int b=Integer.parseInt(temp[1]);
			out.println(pri[a]-pri[b]);
		}
		out.flush();
	}
	public static void main(String[] args) throws Exception{
		p4();
	}


}