# Practice on Toph

Participate in exhilarating programming contests, solve unique algorithm and data structure challenges and be a part of an awesome community.

Participate in exhilarating programming contests, solve unique algorithm and data structure challenges and be a part of an awesome community.

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.

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**.

- 1 <= T <= 1000000
- 5 <= Ax, Ay <=1000000000
- 1<= Sx, Px < Ax
- 1 <= Sy, Py < Ay

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}.

Input | Output |
---|---|

1 10 10 4 3 8 3 | 7.21110256 |

38% Solution Ratio

Tareq_AbrarEarliest,

JUNIORHMMC_CODFastest, 0.0s

Tareq_AbrarLightest, 131 kB

Daiyan_DahyShortest, 553B

Login to submit