#K11426. Cube Faces Reconstruction

    ID: 23466 Type: Default 1000ms 256MiB

Cube Faces Reconstruction

Cube Faces Reconstruction

You are given six square tiles, each with a side length provided as an integer. These tiles are candidates to form the six faces of a cube. A cube is valid if and only if all its faces are squares of the same size, i.e. if all six integers are equal. Formally, if the six side lengths are (a_1, a_2, a_3, a_4, a_5, a_6), the cube is valid if (a_1 = a_2 = a_3 = a_4 = a_5 = a_6). If they are, output the string "VALID". Otherwise, you must determine the minimum side length required for an additional square tile such that the new set can form a cube. In this problem, the answer in the invalid case is simply (\max{a_1, a_2, a_3, a_4, a_5, a_6}).

inputFormat

The input is read from standard input (stdin). The first line contains a single integer (T) (the number of test cases). Each of the following (T) lines contains exactly six space-separated integers representing the side lengths of the six square tiles.

outputFormat

For each test case, print a single line to standard output (stdout). If all six side lengths are equal, output "VALID". Otherwise, output the maximum side length among the six integers.## sample

1
4 4 4 4 4 4
VALID

</p>