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.io.BufferedWriter;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.InputMismatchException;
import java.util.LinkedList;

public class P1 {
	static int[] numberOfPrimeFactors;
	static int[] dp;
	static int sum = 0;

	public static void main(String[] args) {
		FastScanner scanner = new FastScanner();
		OutputWriter out = new OutputWriter(System.out);
		int t = scanner.nextInt();

		numberOfPrimeFactors = new int[5000001];
		dp = new int[5000001];

		numberOfPrimeFactors[2] = 1;
		sum++;
		dp[2] = sum;
		numberOfPrimeFactors[3] = 1;
		sum++;
		dp[3] = sum;
		for (int i = 4; i <= 5000000; i++) {
			setPrime(i);
		}

		for (int i = 0; i < t; i++) {
			int a = scanner.nextInt();
			int b = scanner.nextInt();
			out.println(dp[a] - dp[b]);
		}
		out.flush();

	}

	static void setPrime(int n) {

		if (n % 2 == 0) {
			numberOfPrimeFactors[n] = 1 + numberOfPrimeFactors[n / 2];
			sum += 1 + numberOfPrimeFactors[n / 2];
			dp[n] = sum;
			return;
		}
		if (n % 3 == 0) {
			numberOfPrimeFactors[n] = 1 + numberOfPrimeFactors[n / 3];
			sum += 1 + numberOfPrimeFactors[n / 3];
			dp[n] = sum;
			return;
		}
		int m = (int) Math.sqrt(n);
		for (int i = 3; i <= m; i += 2) {
			if (n % i == 0) {
				numberOfPrimeFactors[n] = numberOfPrimeFactors[i] + numberOfPrimeFactors[n / i];
				sum += numberOfPrimeFactors[i] + numberOfPrimeFactors[n / i];
				dp[n] = sum;
				return;
			}
		}
		numberOfPrimeFactors[n] = 1;
		sum++;
		dp[n] = sum;
		return;
	}
}

class FastScanner {

	private InputStream stream;
	private byte[] buf = new byte[1024];
	private int curChar;
	private int numChars;

	public FastScanner() {
		this.stream = System.in;
	}

	public FastScanner(InputStream stream) {
		this.stream = stream;
	}

	public FastScanner(String fileName) {
		try {
			this.stream = new FileInputStream(fileName);
		} catch (FileNotFoundException e) {
			e.printStackTrace();
		}
	}

	public int nextChar() {
		if (numChars == -1)
			throw new InputMismatchException();
		if (curChar >= numChars) {
			curChar = 0;
			try {
				numChars = stream.read(buf);
			} catch (IOException e) {
				throw new InputMismatchException();
			}
			if (numChars <= 0)
				return -1;
		}
		return buf[curChar++];
	}

	public int nextInt() {
		int c = nextChar();
		while (isSpaceChar(c))
			c = nextChar();
		int sgn = 1;
		if (c == '-') {
			sgn = -1;
			c = nextChar();
		}
		int res = 0;
		do {
			if (c < '0' || c > '9')
				throw new InputMismatchException();
			res *= 10;
			res += c - '0';
			c = nextChar();
		} while (!isSpaceChar(c));
		return res * sgn;
	}

	public long nextLong() {
		int c = nextChar();
		while (isSpaceChar(c))
			c = nextChar();
		int sgn = 1;
		if (c == '-') {
			sgn = -1;
			c = nextChar();
		}
		long res = 0;
		do {
			if (c < '0' || c > '9')
				throw new InputMismatchException();
			res *= 10;
			res += c - '0';
			c = nextChar();
		} while (!isSpaceChar(c));
		return res * sgn;
	}

	public String readString() {
		int c = nextChar();
		while (isSpaceChar(c))
			c = nextChar();
		StringBuilder res = new StringBuilder();
		do {
			res.appendCodePoint(c);
			c = nextChar();
		} while (!isSpaceChar(c));
		return res.toString();
	}

	private boolean isSpaceChar(int c) {
		return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
	}

	public String next() {
		return readString();
	}
}

class OutputWriter {
	private PrintWriter writer;

	public OutputWriter() {
		writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));
	}

	public OutputWriter(OutputStream outputStream) {
		writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(outputStream)));
	}

	public OutputWriter(String fileName) {
		try {
			writer = new PrintWriter(fileName);
		} catch (FileNotFoundException e) {
			e.printStackTrace();
		}
	}

	public void print(Object s) {
		writer.print(s);
	}

	public void println(Object s) {
		writer.println(s);
	}

	public void close() {
		writer.close();
	}

	public void flush() {
		writer.flush();
	}
}