To Go or Not to Go

Wyest and Winsty are two lazy kids who'd rather eat some snacks in the dorm than go to the dining hall. Wyest, however, wants to be healthy occasionally, then she'd persuade Winsty to have meals together, with the reason "Vitta will love you more if you grow some muscle". Since Wyest likes it uncertain, she comes up with a way to decide whether they should step out of their dorms at dinner time.

They randomly choose two positive integers x, y and decide whether they're going or not by the low -th bit of x (where l is the length of x in binary representation, and define the lowest bit to be the zeroth). If the bit is an '1', they get up to the dining hall, or they just continue staying in front of their computers. Now Wyest wonders what the probability of their having meals is, if they give a range to x.

Input

The first line of input is the number of test cases T, then T lines follow, each is a test case with two positive integers a and b, both not larger than 50,000,000. a is guaranteed not to be larger than b. x is randomly chosen from the interval [a,b]. No limit on y.

Output

For each case in the input, output a separate line containing the probability (accurate to 6 fractional digits) of getting an '1' in the way described above and clarified below.

Sample Input

1
4 5
Sample Output

0.500000

http://blog.csdn.net/wh991/article/details/7680717

http://blog.csdn.net/crazy_ac/article/details/7784575