
The robot Romy lives on a cube-shaped planet. Romy has lived alone on the surface of this planet for 30 years. One day he received a transmission from Nancy, a robot who had crash-landed on the planet. Because of the crash, Nancy's motion control system is broken and she cannot move on her own. To repair Nancy, Romy wants to reach the coordinates she gave him by the shortest possible route. However, Romy may travel only along the surface of the planet (the cube); he cannot pass through its interior. In the figure below, the red circle is Romy, the green triangle is Nancy, and the dotted line shows the shortest path between the two points along the surface of the cube.
Input is given through standard input. The cube occupies the region [0,8]×[0,8]×[0,8], and the orientation of each axis is as shown in the figure above. The first line contains the number of test cases T (1≤T≤20). Each test case consists of two lines. The first line contains three integers x1, y1, z1, the x, y, z coordinates of Romy's initial position, separated by single spaces. The second line contains three integers x2, y2, z2, the coordinates of Nancy's initial position. Romy's z coordinate is always 8, so Romy's initial position lies on the top face of the cube. Both initial positions are points on the surface of the cube.
For each test case, print on its own line the square of the length of the shortest path between Romy and Nancy along the surface of the cube.