Finding the Weakness in the Encryption

Time limit1sMemory limit128 MB

Problem

You want to encrypt and transmit some data given as eight 32-bit unsigned integers.

$$ N_1\ N_2\ N_3\ \ldots\ N_8 $$

First, to check that the data is correct, you compute a checksum and append it as a ninth value. (A checksum is a common way to verify data integrity.)

$$ N_9 = \left(\sum_{i=1}^{8} N_i\right) \bmod 2^{32} $$

Then you encrypt these nine numbers with a 32-bit key $K$. Encryption is done with the XOR operation. (XOR is an operation frequently used to encrypt data.)

$$ M_1 = N_1 \oplus K,\quad M_2 = N_2 \oplus K,\quad \ldots,\quad M_9 = N_9 \oplus K $$

If you transmit the nine values $M_1$ through $M_9$, anyone who knows $K$ can recover the original data $N_1$ through $N_8$. And someone who does not know $K$ can recover $N_1$ through $N_8$ as well... surprisingly!

This scheme has a weakness. Exploit it: given the nine integers $M_1$ through $M_9$ in hexadecimal, write a program that finds the key $K$.

Input

The first line contains the number of test cases $T$. $T$ does not exceed $1000$.

Then, for each test case, nine integers $M_1$ through $M_9$ are given in hexadecimal. Each hexadecimal number uses only the digits 0–9 and the lowercase letters a–f, with no unnecessary leading zeros. The nine numbers of a test case are not necessarily all on one line.

Output

For each test case, print the key $K$ in lowercase hexadecimal on its own line, with no unnecessary leading zeros.

Hint

Spoiler warning. The key is the relation $N_9 = \left(\sum_{i=1}^{8} N_i\right) \bmod 2^{32}$. When you add the eight values $N_i = M_i \oplus K$, the parity of the bit sum at each position does not depend on that position's key bit $k_j$. So, starting from the least significant bit and tracking the addition carry, you can determine each bit of $K$ uniquely, one at a time.