Random Integers Random Bits
Difficulty: Hard

Given an integer range [A,B],  

1. What’s the probability to get a 1-bit if we first randomly choose a number x in the range and then randomly choose a bit from x?  
2. What’s the expected number of bit 1s if we randomly choose a number x in the range?  

**Input Format**  
The first line of input is the number of test cases $T$  
Each test cases is a line contains 2 integers $A$ and $B$ separated by a space. 

**Output Format**  
For each test case output a line containing 2 float numbers separated by a space. The first one is the probability and the second one is the expected number. You should output the number accurate to 5 fractional digits. 


**Constraints**  
$1 \le T \le 200$  
$1 \le A \le B \le 10^{10}$  

**Sample Input**

	1
	2 4

**Sample Output**
	
    0.61111 1.33333

**Explanation**  
(10)  (11)  (100)  
(1) So we got a one in $\frac{1}{3} \times \frac{1}{2} + \frac{1}{3} \times \frac{1}{1} + \frac{1}{3} \times \frac{1}{3} = \frac{11}{18}$  
(2) The expected 1 we have is : $1 \times \frac{1}{3} + 2 \times \frac{1}{3} + 1 \times \frac{1}{3} = \frac{4}{3}$  




Input Format:

Output Format:

Sample Input:

Sample Output:

Python 3 starter code:


Reference solution (Python):
###Python 2  
```python  
LIM = 1111
S = [0.0]*LIM # precompute S[n] = sum(0<=k<n) 2^(k-1)/(k+1)
p2 = 0.5
for i in xrange(1,LIM): 
    S[i] = S[i-1] + p2/i
    p2 *= 2

def bit_length(n):
    ''' Length of the binary representation of n '''
    return len(bin(n)[2:])

def bit_count(n):
    ''' Number of 1 bits of n '''
    return sum(map(int, bin(n)[2:]))

def bit_sum(n):
    ''' sum of bit_count(k) for 0<=k<n '''
    return b1(n, bit_count(n)) + b2(n)

def b1(n,b):
    if n == 0: return 0
    if n & 1:  return b1(n-1, b-1) + b-1
    return b1(n>>1, b) << 1

def b2(n):
    if n == 0: return 0
    return (b2(n>>1) << 1) + (n>>1)

for cas in xrange(input()):
    A, B = map(int, raw_input().strip().split())
    C = B+1. - A

    lA, bA = bit_length(A),   bit_sum(A)
    lB, bB = bit_length(B+1), bit_sum(B+1)
    fA = S[lA] + bA/float(lA)
    fB = S[lB] + bB/float(lB)

    print "%.5f %.5f" % (
        (fB - fA) / C,
        (bB - bA) / C,
    )
```