#P1633. 二进制

二进制

Description

There are three integers A,B,CA, B, C, where N(2)N_{(2)} denotes the binary representation of NN (without leading 0s).

Let LL be the maximum length among A(2),B(2),C(2)A_{(2)}, B_{(2)}, C_{(2)}. You need to construct three positive integers X,Y,ZX, Y, Z that satisfy the following conditions:

  1. The lengths of X(2),Y(2),Z(2)X_{(2)}, Y_{(2)}, Z_{(2)} do not exceed LL.
  2. The number of 1s in A(2)A_{(2)} equals that in X(2)X_{(2)}.
  3. The number of 1s in B(2)B_{(2)} equals that in Y(2)Y_{(2)}.
  4. The number of 1s in C(2)C_{(2)} equals that in Z(2)Z_{(2)}.
  5. X+Y=ZX + Y = Z.

Input Format

The first line contains a positive integer TT, indicating there are TT test cases.

The next TT lines each contain three positive integers A,B,CA, B, C.

Output Format

Output TT lines, one answer per line.

Output the minimal ZZ. If there is no valid ZZ, output 1-1.

4
7 6 9
1 1 1
1 1 4
3 3 9
10
-1
2
6

Hint

Constraints and Notes

  • For 30% of the testdata, 1A,B,C1001 \le A, B, C \le 100.
  • For 100% of the testdata, 1T101 \le T \le 10, 1A,B,C2301 \le A, B, C \le 2^{30}.

Translated by ChatGPT 5