Problems
543 - XOR (exclusive or) ^
SUBMIT PROBLEM

XOR (exclusive or) ^

Time Limit: 1 sec

 

The Problem

The Bitwise XOR (exclusive or) performs a logical XOR function, which is equivalent to adding two bits and discarding the carry. The result is zero only when we have two zeroes or two ones. XOR can be used to toggle the bits between 1 and 0. Thus i = i ^ 1 when used in a loop toggles its values between 1 and 0.

 

Bitwise XOR (exclusive or) "^"

bit a bit b a ^ b (a XOR b)
0 0 0
0 1 1
1 0 1
1 1 0

 

You will be given a series of integers as input. You have to output their Exclusive or (XOR) as output.

 

For example,

if A = 5 and B = 4, then in binary A = 101 and B = 100.

So (A XOR B) = (5 XOR 4) = ( 101 XOR 100 ) = 001 (binary) = 1 (decimal)

 

 

The Input

The first line contains a positive integer T ( 1<=T<=100), denoting the number of test case. For each test case input have two lines, first line contain an integer N, the number of integers in the series(1<N<1000) and the second line contain series of N integers X(0<=X<=100000).

 

The Output

For each case, print Exclusive or (XOR) of all numbers in series in a seperate line.

 

Sample Input

3

4

1 2 3 4

3

1 2 3

5

10 5 20 18 2

 

Sample Output

4

0

11

 

 

 

Problem Setter: Shahin ShamS