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.Arrays;
import java.util.HashMap;
import java.util.Map;
import java.util.StringTokenizer;

public class J {
  static int MAX = 5000000;
  static int MAXSQRT = 2237;
  static int[] parent = new int[MAX + 1];

  public static void main(String[] args) throws IOException {
    Reader reader = new Reader();
    reader.initConsoleReading();
    Arrays.fill(parent, -1);
    for (int i = 2; i <= MAXSQRT; i++) {
      if (parent[i] == -1) {
        for (int j = i + i; j <= MAX; j += i) {
          parent[j] = i;
        }
      }
    }
    int[] dp = new int[MAX + 1];
    int[] sum = new int[MAX + 1];
    Arrays.fill(dp, 0);
    Arrays.fill(sum, 0);
    for (int i = 2; i <= MAX; i++) {
      if (parent[i] == -1) {
        dp[i] = 1;
      } else {
        dp[i] = 1 + dp[i / parent[i]];
      }
      sum[i] = sum[i - 1] + dp[i];
    }

    int kase = reader.nextInt();
    //int[] ans = new int[kase + 1];
    OutputStream outputStream = System.out;
    PrintWriter out = new PrintWriter(outputStream);
    for (int ks = 1; ks <= kase; ks++) {
      int a = reader.nextInt(), b = reader.nextInt();
      out.println(sum[a] - sum[b]);
      //ans[ks] = sum[a] - sum[b];
    }
//    for (int ks = 1; ks <= kase; ks++) {
//      System.out.println(ans[ks]);
//    }
    out.close();
    reader.dispose();
  }

  /**
   * **********************************Helper Methods Begin
   * Here*********************************************
   */
  private static String reverse(String toRev) {
    return new StringBuilder(toRev).reverse().toString();
  }

  public static class Pair<F extends Comparable<F>, S extends Comparable<S>>
      implements Comparable<Pair<F, S>> {
    static final int prime = 31;
    private F first;
    private S second;

    public Pair(F f, S s) {
      this.first = f;
      this.second = s;
    }

    @Override
    public int hashCode() {
      int result = 1;
      result = prime * result + this.first.hashCode();
      result = prime * result + this.second.hashCode();
      return result;
    }

    @Override
    public boolean equals(Object obj) {
      if (this == obj) return true;
      if (obj == null) return false;
      if (getClass() != obj.getClass()) return false;
      Pair<F, S> s = (Pair<F, S>) obj;
      return this.first.equals(s.first) && this.second.equals(s.second);
    }

    @Override
    public int compareTo(Pair<F, S> p) {
      int c1 = this.first.compareTo(p.first);
      if (c1 == 0) {
        return this.second.compareTo(p.second);
      }
      return c1;
    }
  }

  public static int swap(int a, int b) {
    /*a = Main.swap(b,b=a); goes from left to right*/
    return a;
  }

  public static long swap(long a, long b) {
    /*a = Main.swap(b,b=a); goes from left to right*/
    return a;
  }

  public static boolean next_permutation(int[] p) {
    for (int a = p.length - 2; a >= 0; --a)
      if (p[a] < p[a + 1])
        for (int b = p.length - 1; ; --b)
          if (p[b] > p[a]) {
            int t = p[a];
            p[a] = p[b];
            p[b] = t;
            for (++a, b = p.length - 1; a < b; ++a, --b) {
              t = p[a];
              p[a] = p[b];
              p[b] = t;
            }
            return true;
          }
    return false;
  }

  public static long gcd(long a, long b) {
    if (a < 0) a *= -1;
    if (b < 0) b *= -1;
    return b == 0 ? a : gcd(b, a % b);
  }

  public static class Reader {
    public BufferedReader reader;
    public StringTokenizer tokenizer;

    public Reader() {}

    public Reader initConsoleReading() {
      reader = new BufferedReader(new InputStreamReader(System.in), 32768);
      tokenizer = null;
      return this;
    }

    public Reader initFileReading(String filePath) throws FileNotFoundException {
      reader = new BufferedReader(new FileReader(filePath), 32768);
      tokenizer = null;
      return this;
    }

    public String next() {
      while (tokenizer == null || !tokenizer.hasMoreTokens()) {
        try {
          tokenizer = new StringTokenizer(reader.readLine());
        } catch (IOException e) {
          throw new RuntimeException(e);
        }
      }
      return tokenizer.nextToken();
    }

    public String nextLine() throws IOException {
      return reader.readLine();
    }

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

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

    public void dispose() throws IOException {
      this.reader.close();
    }
  }
  /**
   * **********************************Helper Methods Ends
   * Here*********************************************
   */
}