# 1046 - Minimum surface distance

Time Limit: 1s Memory Limit: 64MB

Submissions: 50 Solved: 2
Description
Now we have a cuboid p = {x, y, z | 0 <= x <= L, 0 <= y <= W, 0 <= z <= H}, and its volume is L * W * H. There are two points A(x1, y1, z1) and B(x2, y2, z2) on the surface of the cuboid. The minimum surface distance from point A to point B is defined as follows, the minimum distance you must walk from point A to point B via the surface of the cuboid. You are asked to calculate the minimum surface distance from point A to point B,
Input
The first line of the input contains an integer t, giving the number of the test cases; Each test case contains three lines: The first line: L, W, H; the second line: x1, y1, z1, the third line: x2, y2, z2. All the numbers are integers and in the range of 0 to 1000(both included).
Output
For each test case, output a line with the result, rounded to the second digit after the decimal point.
Sample Input
```1
5 5 2
3 1 2
3 5 0```
Sample Output
`6.00`
Hint
Source
lshmouse