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:
//package Soldier_and_Numbe_Game;

import java.io.IOException;
import java.io.PrintWriter;

/**
 * Created by kanghuang on 5/22/15.
 */
public class D {
//    int N = 5000000;
//    int []prime = new int[N/10];
//    int num_prime = 0;
//    boolean isNotPrime[] = new boolean[N];
//    public void filter_prime(){
//        prime[0] = 0;
//        isNotPrime[0] = true;
//        isNotPrime[1] = true;
//        for(int i = 2 ; i < N ; i ++)
//        {
//            if(! isNotPrime[i])
//                prime[num_prime ++]=i;
//            //关键处1
//            for(int j = 0 ; j < num_prime && i * prime[j] <  N ; j ++)
//            {
//                isNotPrime[i * prime[j]] = true;
//                if( (i % prime[j] ) == 0)  //关键处2
//                    break;
//            }
//        }
//    }
    /********** slow version did not notice use dp to avoid repeated calculation
    public static void main(String[] args) {
        D solution = new D();
        solution.filter_prime();
        // System.out.print(solution.num_prime + " " + solution.prime[solution.num_prime-1]);
        int N = 0;
        int number [] = new int[1000000+1];
        for (int i = 2; i <= 1000000; i++) {
            int c = 0, temp = 0;
            while (c < solution.num_prime && solution.prime[c] <= i) {
                int k = 0;
                while (i % (Math.pow(solution.prime[c], k+1)) == 0) {
                    k++;
                }
                temp += k;
                c++;
            }
            if (temp == 0){
                temp = 1;
            }
            number[i] = temp;
        }
        Scanner reader = new Scanner(System.in);
        N = reader.nextInt();
        while (N > 0) {
            N--;
            int a, b;
            a = reader.nextInt();
            b = reader.nextInt();
            int num = 0;
            for (int i = b+1; i <= a; i++) {
                num += number[i];
            }
            System.out.println(num);
        }
    }
     *****************/
    static PrintWriter out = new PrintWriter(System.out);
    public static void main(String[] args) throws IOException {
        int N = 5000002;
        int firstDiv[] = new int[N];
        firstDiv[1] = 0;
        for (int i = 2; i < N; i++){
            if(firstDiv[i] != 0){
                continue;
            }
            else{
                firstDiv[i] = i;
            }
            for (int j = i * i ; j < N && i < Math.sqrt(N); j += i){
                firstDiv[j] = i;
            }
        }
        int number[] = new int[N];
        for (int i = 2; i < N; i++){
            number[i] = number[i/firstDiv[i]]+1;
        }
        int acc[] = new int[N];
        for (int i = 2; i < N; i++){
            acc[i] = acc[i-1] + number[i];
        }
        Reader reader = new Reader();
        N = reader.nextInt();
        while (N > 0) {
            N--;
            int a, b;
            a = reader.nextInt();
            b = reader.nextInt();
            out.println(acc[a] - acc[b]);
        }
        out.close();

    }

    static class Reader {
        final private int BUFFER_SIZE = 1 << 12; private byte[] buffer; private int bufferPointer, bytesRead; private boolean eof = false;
        public Reader() {buffer = new byte[BUFFER_SIZE];bufferPointer = bytesRead = 0;}
        public boolean reachedEOF() {return eof;}
        private void fillBuffer() throws IOException {bytesRead = System.in.read(buffer, bufferPointer = 0, BUFFER_SIZE); if (bytesRead == -1) { buffer[0] = -1;eof = true;}}
        private byte read() throws IOException {if (bufferPointer == bytesRead)fillBuffer();return buffer[bufferPointer++];}
        public String next() throws IOException {StringBuilder sb = new StringBuilder();byte c;while ((c = read()) <= ' ') {if (c == -1)return null;} do {sb.append((char) c);} while ((c = read()) > ' ');if (sb.length() == 0)return null;return sb.toString();}
        public String nextLine() throws IOException {StringBuilder sb = new StringBuilder();byte c;boolean read = false;while ((c = read()) != -1) {if (c == '\n') {read = true;break;}if (c >= ' ')sb.append((char) c);}if (!read)return null;return sb.toString();}
        public int nextInt() throws IOException {int ret = 0;byte c = read();while (c <= ' ')c = read();boolean neg = (c == '-');if (neg)c = read();do {ret = ret * 10 + c - '0';} while ((c = read()) >= '0' && c <= '9');if (neg)return -ret;return ret;}
        public long nextLong() throws IOException {long ret = 0;byte c = read();while (c <= ' ')c = read();boolean neg = (c == '-');if (neg)c = read();do {ret = ret * 10L + c - '0';} while ((c = read()) >= '0' && c <= '9');if (neg)return -ret;return ret;}
        public double nextDouble() throws IOException {double ret = 0, div = 1;byte c = read();while (c <= ' ')c = read();boolean neg = (c == '-');if (neg)c = read();do {ret = ret * 10 + c - '0';} while ((c = read()) >= '0' && c <= '9');if (c == '.')while ((c = read()) >= '0' && c <= '9')ret += (c - '0') / (div *= 10);if (neg)return -ret;return ret;}
        public int[] nextIntArray(int n) throws IOException {int[] a = new int[n];for (int i = 0; i < n; i++)a[i] = nextInt();return a;}
        public int[][] nextIntMatrix(int n, int m) throws IOException {int[][] map = new int[n][m];for (int i = 0; i < n; i++)map[i] = nextIntArray(m);return map;}
        public char[][] nextCharacterMatrix(int n) throws IOException {char[][] a = new char[n][];for (int i = 0; i < n; i++)a[i] = next().toCharArray();return a;}
        public void close() throws IOException {if (System.in == null)return;System.in.close();}
    }

}