Quick Brown Fox and the Lazy Dog

Limits 1s, 512 MB

In every game, the quick brown fox jumps over the lazy dog. But now, the fox decided to test the dog with another game. The dog is standing in a rectangular field surrounded by fence and has to go to another point P(Px,Py) within the field. But as the dog is lazy, the fox decided to give him a bit tougher task.

Initially, the dog is standing on the point S(Sx,Sy). According to the game, he has to touch the fence first and then go to that specific point P. But as we all know, the dog is really very lazy, so only wants to travel the shortest distance. Consider the bottom left corner of the rectangle to be the point origin O(0,0) and the right top corner to be A(Ax,Ay).

Now, you are given the coordinates of P,S and A. Find the minimum distance the dog wants to travel.

Input

The first line takes the number of test cases T.
The following T cases take two lines of input. First line consists of the integers Ax and Ay. The second line consists of four integers, Sx, Sy, Px, Py.

Output

For each case, print the minimum distance the dog wants to travel to finish the game. Errors in the answer should not be greater than 10-4.

Sample

InputOutput
1
10 10
4 3 8 3
7.21110256