#K58347. Single Number

    ID: 30622 Type: Default 1000ms 256MiB

Single Number

Single Number

Given an array of integers where every element appears exactly twice except for one unique element that appears only once, your task is to find and print this single number.

The solution relies on the properties of the XOR operation: specifically, \(a \oplus a = 0\) and \(0 \oplus a = a\). In other words, if you take the XOR of all the numbers in the array, the result will be the unique number.

inputFormat

The input is read from stdin and has the following format:

T
n1 a1 a2 ... an1
n2 b1 b2 ... bn2
...
nT c1 c2 ... cnT

Here, the first line contains an integer \(T\), the number of test cases. For each test case, the first number is an integer \(n\) denoting the number of elements, followed by \(n\) space-separated integers. It is guaranteed that in each test case every element appears exactly twice except for the one that appears once.

outputFormat

For each test case, output the single number on a new line to stdout.

## sample
5
3 2 2 1
5 4 1 2 1 2
5 1 1 2 2 3
5 10 10 20 30 30
1 99
1

4 3 20 99

</p>