The Ant Robot

Given the side lengths of a rectangular box, compute the squared length of the shortest surface path between opposite corners.

Medium5GeometryMathNo attempts yetTime limit1sMemory limit256 MB

Problem

Seunghyun's eraser is a rectangular box. After spending the whole vacation doing nothing in his room, he noticed an ant sitting on the eraser. The ant is not a real ant. It is a robot that someone left in the room.

A path along the surface of a rectangular eraser from corner A to the diagonally opposite corner B

The ant robot moves only over the surface of the eraser. It cannot cut through the inside, and it cannot fly. It walks from one corner AA of the eraser to the diagonally opposite corner BB along a shortest path on the surface, and it leaves a mark everywhere it passes. Treat the robot as a point with no size.

Seunghyun hates marks on his eraser and wants to claim damages, so he needs the length of the mark, which is the distance the robot traveled. Given the three side lengths of the eraser, compute that distance for him.

Input

The first line contains the number of test cases TT. (1T1000001 \le T \le 100\,000)

Each of the next TT lines contains three integers aa, bb, cc separated by spaces. aa is the width of the eraser, bb is the depth, and cc is the height. (1a,b,c1000001 \le a, b, c \le 100\,000)

Output

For each test case, print the square of the distance the ant robot traveled, one value per line. Seunghyun does not want any rounding error, so print the square of the distance instead of the distance itself. This value is always an integer.