Circle

Time Limit: 2000 ms Memory Limit: 65536 KiB

Problem Description

You have been given a circle from 0 to n - 1. If you are currently at x, you will move to (x - 1) mod n or (x + 1) mod n with equal probability. Now we want to know the expected number of steps you need to reach x from 0.

Input

The first line contains one integer T — the number of test cases.
 
Each of the next T lines contains two integers n, x (0  ≤ x < n ≤ 1000) as we mention above.

Output

For each test case. Print a single float number — the expected number of steps you need to reach x from 0. The figure is accurate to 4 decimal places.

Sample Input

3
3 2
5 4
10 5

Sample Output

2.0000
4.0000
25.0000

Hint

 

Source

2014年山东省第五届ACM大学生程序设计竞赛