Problems
Spider and Fly - 2
Spider and Fly - 2
In the empty rectangular room with the length А, the width В and the height С the fly fall onto the floor and fall a sleep. A spider which is lying on one of the walls or on the floor, or on the ceiling, starts moving to the fly by the shortest path.
What distance will it cover?
Input data
The first line contains the sizes of the room А, В, С. The second line contains the coordinates of the fly on the floor X1, Y1, (0 ≤ X1 ≤ A, 0 ≤ Y1 ≤ B). The third line contains the coordinates of the spider X2, Y2, Z2, (0 ≤ X2 ≤ A, 0 ≤ Y2 ≤ B, 0 ≤ Z2 ≤ C). All input values are integer nonnegative numbers less then or equal to 500.
Output data
The only number – the distance which will be covered by the spider with two digits after the decimal point.
Examples
Input example #37
4 7 3 2 1 3 7 2
Output example #37
8.06