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.*;
import java.util.*;

public class D {
    public static void solution(BufferedReader reader, PrintWriter writer)
            throws IOException {
        In in = new In(reader);
        Out out = new Out(writer);
        int MAX = 5000000;
        int[] d = new int[MAX + 1];
        int[] A = new int[MAX + 1];
        for (int i = 2; i <= MAX; i++)
            d[i] = i;
        for (int i = 2; i <= MAX; i++)
            if (d[i] > 1) {
                A[i]++;
                if (i <= Math.sqrt(MAX))
                    for (int j = i * i; j <= MAX; j += i)
                        while (d[j] % d[i] == 0) {
                            d[j] /= d[i];
                            A[j]++;
                        }
            }
        SegmentTree st = new SegmentTree(A);
        int t = in.nextInt();
        for (int i = 0; i < t; i++) {
            int a = in.nextInt(), b = in.nextInt();
            out.println(a == b ? 0 : st.sum(b + 1, a + 1));
        }
    }

    protected static class SegmentTree {
        private int[] M; // M[0] is never used
        private int n;

        // O(n)
        public SegmentTree(int[] A) {
            n = A.length;
            M = new int[n << 1];
            for (int i = 0; i < n; i++)
                M[i + n] = A[i];
            for (int i = n - 1; i > 0; i--)
                M[i] = M[i << 1] + M[i << 1 | 1];
        }

        // [from, to) O(logn)
        public int sum(int from, int to) {
            int sum = 0;
            for (from += n, to += n; from < to; from >>= 1, to >>= 1) {
                if ((from & 1) > 0)
                    sum += M[from++];
                if ((to & 1) > 0)
                    sum += M[--to];
            }
            return sum;
        }

        // A[i] = v O(logn)
        public void set(int i, int v) {
            for (M[i += n] = v; i > 1; i >>= 1)
                M[i >> 1] = M[i] + M[i ^ 1];
        }

        // A[i] += v O(logn)
        public void add(int i, int v) {
            for (M[i += n] += v; i > 1;)
                M[i >>= 1] += v;
        }
    }

    public static void main(String[] args) throws Exception {
        BufferedReader reader = new BufferedReader(
                new InputStreamReader(System.in));
        PrintWriter writer = new PrintWriter(
                new BufferedWriter(new OutputStreamWriter(System.out)));
        solution(reader, writer);
        writer.close();
    }

    protected static class In {
        private BufferedReader reader;
        private StringTokenizer tokenizer = new StringTokenizer("");

        public In(BufferedReader reader) {
            this.reader = reader;
        }

        public String next() throws IOException {
            while (!tokenizer.hasMoreTokens())
                tokenizer = new StringTokenizer(reader.readLine());
            return tokenizer.nextToken();
        }

        public int nextInt() throws IOException {
            return Integer.parseInt(next());
        }

        public long nextLong() throws IOException {
            return Long.parseLong(next());
        }

        public double nextDouble() throws IOException {
            return Double.parseDouble(next());
        }

        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[] nextIntArray1(int n) throws IOException {
            int[] a = new int[n + 1];
            for (int i = 1; i <= n; i++)
                a[i] = nextInt();
            return a;
        }

        public int[] nextIntArraySorted(int n) throws IOException {
            int[] a = nextIntArray(n);
            Random r = new Random();
            for (int i = 0; i < n; i++) {
                int j = i + r.nextInt(n - i);
                int t = a[i];
                a[i] = a[j];
                a[j] = t;
            }
            Arrays.sort(a);
            return a;
        }

        public long[] nextLongArray(int n) throws IOException {
            long[] a = new long[n];
            for (int i = 0; i < n; i++)
                a[i] = nextLong();
            return a;
        }

        public long[] nextLongArray1(int n) throws IOException {
            long[] a = new long[n + 1];
            for (int i = 1; i <= n; i++)
                a[i] = nextLong();
            return a;
        }

        public long[] nextLongArraySorted(int n) throws IOException {
            long[] a = nextLongArray(n);
            Random r = new Random();
            for (int i = 0; i < n; i++) {
                int j = i + r.nextInt(n - i);
                long t = a[i];
                a[i] = a[j];
                a[j] = t;
            }
            Arrays.sort(a);
            return a;
        }
    }

    protected static class Out {
        private PrintWriter writer;
        private static boolean local = System
                .getProperty("ONLINE_JUDGE") == null;

        public Out(PrintWriter writer) {
            this.writer = writer;
        }

        public void print(char c) {
            writer.print(c);
        }

        public void print(int a) {
            writer.print(a);
        }

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

        public void println(int a) {
            writer.println(a);
        }

        public void println(long a) {
            writer.println(a);
        }

        public void println(Object[] os) {
            for (int i = 0; i < os.length; i++) {
                writer.print(os[i]);
                writer.print(' ');
            }
            writer.println();
        }

        public void println(int[] a) {
            for (int i = 0; i < a.length; i++) {
                writer.print(a[i]);
                writer.print(' ');
            }
            writer.println();
        }

        public void println(long[] a) {
            for (int i = 0; i < a.length; i++) {
                writer.print(a[i]);
                writer.print(' ');
            }
            writer.println();
        }

        public static void db(Object... objects) {
            if (local)
                System.out.println(Arrays.deepToString(objects));
        }
    }
}