Jaehyun has become convinced that the Earth ought to be shaped like a rectangular box. So he carried out a massive project to reshape the Earth into a rectangular cuboid whose edge lengths are ℓx×ℓy×ℓz. Now every location on the Earth's surface can be described by 3D Cartesian coordinates, and the cuboid occupies the region 0≤x≤ℓx, 0≤y≤ℓy, 0≤z≤ℓz. Jaehyun built his house at the vertex (0,0,0).
Meanwhile, Seungwon's house was forcibly relocated to the coordinates (x,y,z) by this project. Seungwon's position always lies on one of the six faces of the cuboid.
Jaehyun wants to travel to Seungwon. Since both houses are on the Earth's surface, Jaehyun may move only along the surface of the cuboid; he cannot pass through its interior. Find the length of the shortest path along the surface from (0,0,0) to (x,y,z).
For example, if ℓx=1, ℓy=2, ℓz=1 and Seungwon is at (1,2,1), the shortest path goes from (0,0,0) through the surface point (1,1,0) to (1,2,1), and its length is 8.
The input consists of several test cases. Each test case is given on a single line as six integers ℓx, ℓy, ℓz, x, y, z (1≤ℓx,ℓy,ℓz≤1000). The coordinates (x,y,z) are guaranteed to lie on one of the six faces of the cuboid. The last line of the input is ℓx=ℓy=ℓz=x=y=z=0, and no answer should be printed for it.
For each test case, print on a single line the square of the length of the shortest surface path, as an integer. (The square of the shortest path length is always an integer, so you must print the exact integer value, not an approximation.)