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 CPP):

Solution:
#include <bits/stdc++.h>
using namespace std;
const int BLACK = 1, WHITE = 2;
int len_of_number(int n) {
  int len(0);
  while (n != 0) {
    ++len;
    n /= 10;
  }
  return len;
}
int sum_of_digits(int n) {
  int sod = 0;
  while (n != 0) {
    sod += (n % 10);
    n /= 10;
  }
  return sod;
}
bool isPalindrome(string str) {
  int n = str.length();
  for (int i = (0); i <= (n / 2); i++)
    if (str[i] != str[n - i - 1]) return false;
  return true;
}
long long int fast_exp(long long int x, long long int i) {
  long long int ans = 1;
  while (i > 0) {
    if (i & 1) ans = (ans * x);
    i >>= 1;
    x = (x * x);
  }
  return ans;
}
long long int fast_exp(long long int x, long long int i, long long int mod) {
  long long int ans = 1;
  while (i > 0) {
    if (i & 1) ans = (ans * x) % mod;
    i >>= 1;
    x = (x * x) % mod;
  }
  return ans;
}
long long int modInverse(long long int x, long long int mod) {
  return fast_exp(x, mod - 2, mod);
}
long long int egcd_x, egcd_y, egcd_d;
void egcd(long long int a, long long int b) {
  if (b == 0) {
    egcd_x = 1, egcd_y = 0;
    egcd_d = a;
    return;
  }
  egcd(b, a % b);
  long long int temp = egcd_x;
  egcd_x = egcd_y;
  egcd_y = temp - (a / b) * egcd_y;
}
long long int extended_gcd(long long int a, long long int b) {
  if (a >= b) {
    egcd(a, b);
    return ((egcd_x % b) + b) % b;
  } else {
    egcd(b, a);
    return ((egcd_y % b) + b) % b;
  }
}
long long int gcd(long long int x, long long int y) {
  long long int t;
  while (y != 0) {
    t = x % y;
    x = y;
    y = t;
  }
  return x;
}
bool isPrime(int n) {
  int root = sqrt(n);
  for (int i = (2); i <= (root); i++)
    if (n % i == 0) return 0;
  return 1;
}
vector<int> cnt;
string groupAndCnt(string str) {
  string a = "";
  int prev_count = 0;
  char prev_char = '~';
  for (auto &c : str) {
    if (c != prev_char) {
      if (prev_count) {
        a += prev_char;
        cnt.push_back(prev_count);
      }
      prev_count = 1;
      prev_char = c;
    } else
      ++prev_count;
  }
  cnt.push_back(prev_count);
  a += prev_char;
  return a;
}
vector<int> pset, pset_size;
void initSet(int _size) {
  pset.resize(_size);
  pset_size.resize(_size);
  for (int i = (0); i <= (_size - 1); i++) pset[i] = i, pset_size[i] = 1;
}
int findSet(int i) { return (pset[i] == i) ? i : (pset[i] = findSet(pset[i])); }
void unionSet(int i, int j) {
  int p1 = findSet(i);
  int p2 = findSet(j);
  pset[p1] = p2;
  if (p1 != p2) {
    pset_size[p2] += pset_size[p1];
  }
}
bool isSameSet(int i, int j) { return findSet(i) == findSet(j); }
int lp[5000001] = {0}, pr[348513] = {0}, ans[5000001] = {0};
void preCompute(int n) {
  int z = 0;
  long long int size = 0;
  for (int i = (2); i <= (n); i++) {
    if (lp[i] == 0) {
      lp[i] = i;
      pr[z++] = i;
      ++size;
    }
    for (long long int j = 0;
         j < size && pr[j] <= lp[i] && 1ll * i * 1ll * pr[j] <= n; ++j)
      lp[i * pr[j]] = pr[j];
  }
}
inline void solve(int T) {
  int a, b;
  scanf("%d %d", &a, &b);
  if (a == b) {
    printf("0\n");
    ;
    return;
  }
  printf("%d\n", ans[a] - ans[b]);
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  preCompute(5000000);
  int num, c;
  for (int i = (2); i <= (5000000); i++) {
    num = i;
    c = 0;
    while (num != 1) {
      num /= lp[num];
      ++c;
    }
    ans[i] = ans[i - 1] + c;
  }
  int test_cases;
  scanf("%d", &test_cases);
  for (int T = (0); T <= (test_cases - 1); T++) {
    solve(T);
  }
  return 0;
}