Question
Equal Quest

Alice holds three numbers A, B, and C. She can perform this operation: choose two of A, B, and C, add 1 to each, and subtract 1 from the third. Determine if Alice can make A, B, and C equal using any number of such operations. If possible, output the minimum number of operations required, else print -1.

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 A, B and C
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 A and C. Thus A and C become 3 + 1 = 4, and 3 + 1 = 4, respectively. Also, B becomes 7 - 1 = 6.
Operation 2: Select the numbers A and C. Thus A and C 4 + 1  = 5, and 4 + 1 = 5 respectively. Also, becomes C becomes 6 - 1 = 5.
Thus, all 3 numbers are equal after 2 operations

Online