Question
Triad Trick
Lila holds three numbers X, Y, and Z. She can perform this operation: Choose two of X, Y, Z, increase each by 1, and decrease the third by 1. Find if Lila can equalize all three numbers using this operation any number of times. If possible, report the minimum number of operations needed.
Input
The first line of input will contain a single integer T, denoting the number of test cases.
Each test case consists of single line containing 3 space-separated integers X, Y and Z.

Constraints
1 ≤ T ≤ 104
1 ≤ X, Y, Z ≤ 109
Output
For each test case, output - 1 if the numbers cannot be made equal, else output the minimum number of operations required to make them equal.
Example
Sample Input
2
1 1 2
3 7 3
Sample Output
-1
2
Explanation
Test case 1: It can be proven that we cannot make the numbers equal using any number of operations.
Test case 2: We require a minimum of 2 operations to make the numbers equal:
Operation 1: Select the numbers X and Z. Thus X and Z become 3 + 1 = 4, and 3 + 1 = 4, respectively. Also, Y becomes 7 - 1 = 6.
Operation 2: Select the numbers X and Z. Thus X and Z 4 + 1  = 5, and 4 + 1 = 5 respectively. Also, becomes Y becomes 6 - 1 = 5.
Thus, all 3 numbers are equal after 2 operations.

Online