Sansa has an array. She wants to find the value obtained by XOR-ing the contiguous subarrays, followed by XOR-ing the values thus obtained. Determine this value.  

Example 

$arr=[3,4,5]$   

Subarray	Operation	Result
3		None		3
4		None		4
5		None		5
3,4		3 XOR 4		7
4,5		4 XOR 5		1
3,4,5		3 XOR 4 XOR 5	2

Now we take the resultant values and XOR them together:

$3\oplus4\oplus5\oplus7\oplus1\oplus2=6$.  Return $\boldsymbol{6}$.   

Function Description  

Complete the sansaXor function in the editor below.  

sansaXor has the following parameter(s):  

int arr[n]:  an array of integers  

Returns   

int: the result of calculations  

Input Format

The first line contains an integer $\boldsymbol{\boldsymbol{t}}$, the number of the test cases.   

Each of the next $\boldsymbol{\boldsymbol{t}}$ pairs of lines is as follows: 

- The first line of each test case contains an integer $n$, the number of elements in $arr$. 

- The second line of each test case contains $n$ space-separated integers $arr[i]$.    

Constraints

$1\leq t\leq5$ 

$2\leq n\leq10^5$ 

$1\leq arr[i]\leq10^8$  

Sample Input 0
2
3
1 2 3
4
4 5 7 5

Sample Output 0
2
0

Explanation 0

Test case 0: 

$1\oplus2\oplus3\oplus(1\oplus2)\oplus(2\oplus3)\oplus(1\oplus2\oplus3)=2$ 

Test case 1: 

$4\oplus5\oplus7\oplus5\oplus(4\oplus5)\oplus(5\oplus7)\oplus(7\oplus5)\oplus(4\oplus5\oplus7)\oplus(5\oplus7\oplus5)\oplus(4\oplus5\oplus7\oplus5)=0$  

Sample Input 1
2
3
98 74 12
3
50 13 2

Sample Output 1
110
48

Explanation 1

Test Case 0:

$98\oplus74\oplus12\oplus(98\oplus74)\oplus(74\oplus12)\oplus(98\oplus74\oplus12)=110$  

Test Case 1:

$50\oplus13\oplus2\oplus(50\oplus13)\oplus(13\oplus2)\oplus(50\oplus13\oplus2)=48$

Difficulty: MEDIUM
Tags: Bit manipulation
Skill types: Bit manipulation

Starter code:

Solutions:
for _ in range(int(input())):
	N = int(input())
	A = tuple(map(int, input().split()))
	X = 0
	for (i, x) in enumerate(A):
		if (i + 1) * (N - i) % 2 == 1:
			X ^= x
	print(X)


t = int(input())
for i in range(t):
	n = int(input())
	x = [int(x) for x in input().split()]
	values = []
	for (i, value) in enumerate(x):
		before = i + 1
		after = len(x) - i
		total_combos = before * after + 1
		if total_combos % 2 == 0:
			values.append(value)
	result = 0
	for val in values:
		result ^= val
	print(result)


tcs = int(input())
for tc in range(tcs):
	num = int(input())
	array = list(map(int, input().split(' ')))
	xor = 0
	if num % 2 == 0:
		print(0)
	else:
		for i in range(0, num, 2):
			xor = xor ^ array[i]
		print(xor)


T = int(input())
for cs in range(T):
	res = 0
	N = int(input())
	a = [int(x) for x in input().split()]
	for (i, elem) in enumerate(a):
		if (i + 1) * (N - i) % 2 == 1:
			res ^= elem
	print(res)


T = int(input())
for _ in range(T):
	N = int(input())
	A = [int(_) for _ in input().split()]
	if N % 2 == 0:
		print(0)
	else:
		s = 0
		for i in range(0, N, 2):
			s ^= A[i]
		print(s)


t = int(input())
i = 0
while i < t:
	n = int(input())
	ar = input().split(' ')
	j = 0
	xor = 0
	n1 = n
	while j < n:
		val = (j + 1) * n1
		n1 = n1 - 1
		if val % 2 != 0:
			xor = xor ^ int(ar[j])
		j = j + 1
	print(xor)
	i = i + 1


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	if n % 2 == 0:
		print(0)
	else:
		xor_sum = 0
		for i in range(0, n, 2):
			xor_sum = xor_sum ^ a[i]
		print(xor_sum)


t = int(input())
for jv in range(t):
	n = int(input())
	s = input().strip().split()
	if n % 2 == 0:
		print(0)
	else:
		ans = int(s[0])
		for k in range(2, n, 2):
			ans ^= int(s[k])
		print(ans)


from sys import stdin
T = int(stdin.readline())
for _ in range(T):
	N = int(stdin.readline())
	A = [int(s) for s in stdin.readline().strip().split()]
	ans = 0
	for i in range(N):
		if i == 0 or i == N - 1:
			if N % 2:
				ans ^= A[i]
		elif (i + 1) * (N - i) % 2:
			ans ^= A[i]
	print(ans)


t = int(input())
for asdf in range(t):
	n = int(input())
	tab = list(map(int, input().split()))
	if n % 2 == 0:
		print(0)
		continue
	result = 0
	for i in range(0, n, 2):
		result = result ^ tab[i]
	print(result)


t = int(input())
for i in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	dp = [1] * (len(a) + 1)
	dp[1] += n - 1
	dp[2] += n - 1 + (n - 2)
	ans = 0
	for i in range(3, n + 1):
		dp[i] += (n - i + 1) * (i - 1) + (n - i)
	for i in range(1, n + 1):
		if dp[i] % 2 == 1:
			ans = ans ^ a[i - 1]
	print(ans)


testcases = int(input())
for _ in range(testcases):
	elems_num = int(input())
	ints = input().split()
	if elems_num % 2 == 0:
		print('0')
	else:
		total = 0
		for i in range(0, int(elems_num / 2), 2):
			total ^= int(ints[i])
			total ^= int(ints[elems_num - i - 1])
		if (elems_num - 1) % 4 == 0:
			total ^= int(ints[int(elems_num / 2)])
		print(total)


num_test = int(input())
for x in range(num_test):
	num_elem = int(input())
	numbers = input().split()
	result = 0
	if num_elem % 2 == 0:
		print(0)
	else:
		for y in range(0, num_elem):
			if y % 2 == 0:
				result = result ^ int(numbers[y])
		print(result)


T = int(input())
for m in range(T):
	N = int(input())
	array = input().split(' ')
	array = [int(x) for x in array]
	val = 0
	if N % 2 == 0:
		print(0)
	else:
		for i in range(0, N, 2):
			val = val ^ array[i]
		print(val)


T = int(input())
for i in range(T):
	N = int(input())
	A = list(map(int, input().split()))
	if N % 2 == 0:
		print(0)
	else:
		result = 0
		for element in A[::2]:
			result ^= element
		print(result)


def xor_cont(nums):
	result = 0
	for (idx, n) in enumerate(nums):
		times = (idx + 1) * (len(nums) - idx)
		result ^= n if times % 2 else 0
	return result
T = int(input())
for _ in range(T):
	N = int(input())
	nums = list(map(int, input().split()))
	print(xor_cont(nums))


from operator import xor
from functools import reduce

def getint():
	return int(input())

def getintlist():
	return [int(i) for i in input().split()]
T = getint()
for _ in range(T):
	N = getint()
	l = getintlist()
	if N % 2 == 0:
		print('0')
	else:
		print(reduce(xor, l[::2]))


a = int(input())
for i in range(a):
	b = int(input())
	c = input().split(' ')
	for j in range(len(c)):
		c[j] = int(c[j])
	if b % 2 == 0:
		print(0)
	else:
		r = 0
		for j in range(0, len(c) + 1, 2):
			r = r ^ c[j]
		print(r)


from operator import mul

def solve():
	T = int(input())
	for _ in range(T):
		N = int(input())
		A = list(map(int, input().split(' ')))
		factors = [x % 2 == 1 for x in map(mul, range(1, N + 1), range(N, 0, -1))]
		answer = 0
		for i in range(N):
			if factors[i]:
				answer ^= A[i]
		print(answer)
solve()


for i in range(0, int(input())):
	input()
	myNums = list(map(int, input().split(' ')))
	if len(myNums) % 2 == 0:
		print(0)
	else:
		xOr = 0
		for i in range(0, len(myNums), 2):
			xOr = xOr ^ myNums[i]
		print(xOr)


for t in [1] * int(input()):
	n = int(input())
	a = list(map(int, input().split()))
	if n % 2 == 0:
		print(0)
	else:
		xor = 0
		for i in range(0, n, 2):
			xor ^= a[i]
		print(xor)


T = int(input())
for alls in range(0, T):
	num = int(input())
	arr = [int(each) for each in input().split(' ')]
	if len(arr) == 1:
		print(arr[0])
	elif len(arr) % 2 == 0:
		print(0)
	else:
		result = 0
		par = 0
		while par < len(arr):
			result ^= arr[par]
			par = par + 2
		print(result)


import sys

def main():
	numCases = int(sys.stdin.readline())
	for caseIndex in range(0, numCases):
		arrayLength = int(sys.stdin.readline())
		inputList = sys.stdin.readline().split()
		if arrayLength % 2 == 0:
			print(0)
		else:
			inputList = list(map(lambda x: int(x), inputList))
			overallXorSum = 0
			for i in range(0, len(inputList)):
				if i % 2 == 0:
					overallXorSum = overallXorSum ^ inputList[i]
			print(overallXorSum)
main()


def my_func(n, a):
	if n % 2 == 0:
		return 0
	mid = n // 2
	res = 0
	for i in range(0, n, 2):
		res ^= a[i]
	return res
for case_t in range(int(input())):
	n = int(input())
	a = [int(i) for i in input().strip().split()]
	print(my_func(n, a))


def appearsInSS(pos, l):
	return 1 + pos + (l - pos - 1) + pos * (l - pos - 1)
for case in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	r = 0
	for i in range(0, len(a)):
		if appearsInSS(i, len(a)) % 2 == 1:
			r ^= a[i]
	print(r)


T = int(input())
for _ in range(T):
	N = int(input())
	A = [int(_) for _ in input().split()]
	if N % 2 == 0:
		print(0)
	else:
		s = 0
		for i in range(0, N, 2):
			s ^= A[i]
		print(s)


import sys
T = int(sys.stdin.readline())
for t in range(T):
	N = int(sys.stdin.readline())
	arr = list(map(int, sys.stdin.readline().split()))
	xor = 0
	for k in range(N):
		times = (k + 1) * (N - k)
		if times % 2 == 1:
			xor ^= arr[k]
	print(xor)


trials = int(input())
for trial in range(trials):
	arr_len = int(input())
	array = [int(x) for x in input().split()]
	xor = 0
	arr_len = len(array)
	for i in range(arr_len):
		if (arr_len - i) * (i + 1) % 2:
			xor ^= array[i]
	print(xor)


T = int(input())
for ncase in range(T):
	N = int(input())
	sq = [int(i) for i in input().split(' ')]
	ans = 0
	for (i, x) in enumerate(sq):
		if (i + 1) * (N - i) % 2 == 1:
			ans ^= x
	print(ans)


T = int(input().strip())
for t in range(T):
	n = int(input().strip())
	arr = [int(i) for i in input().strip().split()]
	result = 0
	if n % 2 == 1:
		for j in range(0, n, 2):
			result ^= arr[j]
	print(result)


def run():
	t = int(input())
	while t > 0:
		t -= 1
		n = int(input())
		a = list(map(int, input().split()))
		if n % 2 == 0:
			print(0)
		else:
			ans = 0
			for x in range(0, n, 2):
				ans ^= a[x]
			print(ans)
run()


def sansa(a):
	if len(a) % 2 == 0:
		return 0
	ret = 0
	for (i, v) in enumerate(a):
		if i % 2 == 0:
			ret ^= v
	return ret
t = int(input().strip())
for _ in range(t):
	input().strip()
	print(sansa(list(map(int, input().strip().split()))))


def solve(n, a):
	if n % 2 == 0:
		return 0
	result = 0
	for i in range(0, n, 2):
		result ^= a[i]
	return result
t = int(input())
for i in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	print(solve(n, a))


from functools import reduce
import sys
numinputs = int(input())
for dummy in range(numinputs):
	n = int(input())
	arr = [int(val) for val in input().split()]
	if n % 2 == 0:
		print(0)
		continue
	op = 0
	for val in arr[0:n:2]:
		op = op ^ val
	print(op)


from collections import defaultdict

def test(array):
	array_len = len(array)
	expr = []
	for i in range(array_len):
		for j in range(i, array_len):
			temp = 0
			for k in range(i, j + 1):
				temp ^= array[k]
			expr.append(temp)
	result = 0
	for e in expr:
		result ^= e
	return result

def solve(array):
	n = len(array)
	temp = array[:]
	if n % 2 != 0:
		for i in range(n):
			if i % 2 != 0:
				temp[i] = temp[i] ^ temp[i]
	else:
		for i in range(n):
			temp[i] = temp[i] ^ temp[i]
	result = 0
	for num in temp:
		result ^= num
	return result

def main():
	T = int(input())
	for i in range(T):
		input()
		nums = [int(i) for i in input().split()]
		print(solve(nums))
main()


t = int(input())
for _ in range(t):
	n = int(input())
	ans = 0
	ar = [int(x) for x in input().split()]
	for (i, x) in enumerate(ar):
		cogs = (i + 1) * (n - i)
		if cogs % 2 == 1:
			ans ^= x
	print(ans)


tCases = int(input(''))
for i in range(tCases):
	nElements = int(input(''))
	elements = [int(n) for n in input('').split(' ')]
	if nElements % 2 == 0:
		print('0')
	else:
		xord = 0
		for j in range(nElements):
			if j % 2 == 0:
				xord = xord ^ elements[j]
		print(str(xord))


testcases = int(input())
for test in range(testcases):
	length = int(input())
	array = [int(i) for i in input().split()]
	if length % 2:
		xor_value = 0
		for i in range(0, len(array), 2):
			xor_value ^= array[i]
		print(xor_value)
	else:
		print(0)


def xor_list(ar):
	len_ar = len(ar)
	ans = 0
	for (i, v) in enumerate(ar):
		x = (i + 1) * (len_ar - i)
		if x % 2 == 1:
			ans ^= v
	return ans
num_test_cases = int(input())
for i in range(num_test_cases):
	input()
	ar = input()
	ar = [int(x) for x in ar.split(' ')]
	print(xor_list(ar))


trials = int(input())
for t in range(trials):
	input()
	nums = [int(num) for num in input().split()]
	if len(nums) % 2 == 0:
		print(0)
	else:
		result = 0
		for i in nums[0::2]:
			result ^= i
		print(result)


for _ in range(int(input())):
	length = int(input())
	ar = list(map(int, input().split(' ')))
	result = 0
	if length % 2:
		i = 0
		while i < length:
			result ^= ar[i]
			i += 2
	print(result)


numcases = int(input())
for _ in range(numcases):
	_ = input()
	s = [int(x) for x in input().split(' ')]
	size = len(s)
	acc = 0
	for (i, e) in enumerate(s):
		numSubsets = (i + 1) * (size - i)
		if numSubsets % 2 == 1:
			acc = acc ^ e
	print(acc)


import functools
T = int(input())
for _ in range(T):
	size = int(input())
	if size % 2 == 0:
		input()
		print(0)
	else:
		numbers = list(map(int, input().split()))
		print(functools.reduce(lambda a, b: a ^ b, numbers[::2], 0))


def allcontigXOR(a):
	if len(a) % 2:
		return XOR(a[::2])
	else:
		return 0

def XOR(a):
	val = 0
	for entry in a:
		val = val ^ entry
	return val
num_cases = int(input())
for case in range(num_cases):
	num_values = int(input())
	values = list(map(int, input().split()))
	print(allcontigXOR(values))


from functools import reduce

def xor(arr):
	reduce()
for _ in range(int(input())):
	n = int(input())
	arr = [int(s) for s in input().split()]
	if n % 2 == 0:
		print(0)
	else:
		print(reduce(lambda x, y: x ^ y, arr[::2]))


n = int(input())
for i in range(n):
	input()
	a = [int(x) for x in input().split()]
	if len(a) % 2 == 0:
		print(0)
	else:
		res = 0
		for j in range(0, len(a), 2):
			res = res ^ a[j]
		print(res)


T = int(input())
for case in range(T):
	N = int(input())
	arr = list(map(int, input().split(' ')))
	ans = 0
	for i in range(N):
		if (i + 1) * (N - i) % 2 == 1:
			ans ^= arr[i]
	print(ans)


def subarray_xor(ns):
	res = 0
	m = len(ns)
	lo = 0
	for i in range(len(ns)):
		o = lo + m
		if o & 1 == 1:
			res ^= ns[i]
		lo = o
		m -= 2
	return res
t = int(input())
for ti in range(t):
	n = int(input())
	ns = list(map(int, input().split(' ')))
	print(subarray_xor(ns))


numtest = int(input())
for z in range(numtest):
	n = int(input())
	arr = [int(x) for x in input().split()]
	if n & 1 == 1:
		ans = arr[0]
		for x in range(2, n, 2):
			ans = ans ^ arr[x]
		print(ans)
	else:
		print('0')


for t in range(int(input())):
	(l, a) = (int(input()), input().split())
	if len(a) % 2 == 1:
		s = 0
		for x in range(l):
			if x % 2 == 0:
				s = s ^ int(a[x])
		print(s)
	else:
		print(0)


from functools import reduce
from operator import xor
t = int(input())
for i in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	if n % 2:
		print(reduce(xor, a[::2]))
	else:
		print(0)


for _ in range(int(input())):
	M = int(input())
	A = [int(i) for i in input().split()]
	if M % 2 == 0:
		print(0)
	else:
		t = 0
		for a in A[::2]:
			t ^= a
		print(t)


T = int(input())
for _ in range(T):
	N = int(input())
	A = [int(x) for x in input().split()]
	c = [0 for _ in range(N)]
	count = 0
	for i in range(N):
		if N - 2 * i > 0:
			count += N - 2 * i
			c[i] = count
		else:
			c[i] = c[N - i - 1]
	r = [x % 2 for x in c]
	res = 0
	for i in range(N):
		if r[i]:
			res = res ^ A[i]
	print(res)


trail = int(input())
while trail:
	trail -= 1
	size = int(input())
	num = list(map(int, input().split()))
	if size % 2 == 0:
		print(0)
		continue
	else:
		xor = 0
		for i in range(0, size, 2):
			xor ^= num[i]
		print(xor)
		continue


def calculate(array):
	temp = []
	n = len(array)
	for i in range(0, len(array)):
		temp.append((i + 1) * (n - i) % 2 == 1)
	result = 0
	for i in range(0, len(array)):
		if temp[i] == True:
			result ^= array[i]
	return result
n = int(input())
for i in range(0, n):
	no = int(input())
	array = []
	for s in input().split():
		array.append(int(s))
	print(calculate(array))


for _ in range(int(input())):
	n = int(input())
	nums = [int(x) for x in input().split()]
	total = 0
	if n % 2 == 0:
		print(0)
	else:
		for i in range(n)[::2]:
			total = total ^ nums[i]
		print(total)


def calc_xor(A):
	if len(A) % 2 == 0:
		return 0
	B = A[::2]
	v = 0
	for i in B:
		v ^= i
	return v
T = int(input())
for i in range(T):
	N = int(input())
	A = [int(i) for i in input().strip().split(' ')]
	print(calc_xor(A))


def getXOR(sl):
	if len(sl) % 2:
		xoro = sl[0]
		for i in range(2, len(sl), 2):
			xoro ^= sl[i]
	else:
		xoro = 0
	print(xoro)
n = int(input().strip())
for tc in range(0, n):
	input()
	sl = [int(x) for x in input().strip().split()]
	getXOR(sl)


T = int(input())
for _ in range(T):
	N = int(input())
	ar = [int(i) for i in input().split()]
	result = 0
	count = 0
	for i in range(N):
		count += N - 2 * i
		if count % 2 == 1:
			result = result ^ ar[i]
	print(result)


t = int(input())
while t > 0:
	n = int(input())
	a = n * [0]
	a = input().split()
	a = [int(i) for i in a]
	res = 0
	for i in range(0, n):
		if (i + 1) * (n - i) % 2 != 0:
			res ^= a[i]
	print(res)
	t -= 1


t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	l = len(a)
	if l % 2 == 0:
		print('0')
	else:
		r = 0
		for i in range(0, l, 2):
			r = r ^ a[i]
		print(r)


import functools
t = int(input())
for _ in range(t):
	n = int(input())
	l = [int(_) for _ in input().split()]
	if n % 2 == 0:
		print(0)
	else:
		print(functools.reduce(lambda x, y: x ^ y, [l[i] for i in range(0, n, 2)]))


from collections import Counter

def sansa_xor(c, s):
	count = Counter()
	res = 0
	for i in range(s):
		count[c[i]] += (s - i - 1) * (i + 1) + (i + 1)
	for i in count:
		if count[i] % 2 == 1:
			res ^= i
	print(res)
	return 0
for _ in range(int(input())):
	_s = int(input())
	_c = list(map(int, input().split()))
	sansa_xor(_c, _s)


nc = int(input())
for ca in range(nc):
	n = int(input())
	res = 0
	for (i, t) in enumerate(input().split()):
		if i + 1 & n & 1 == 1:
			res ^= int(t)
	print(res)


T = int(input())
for t in range(T):
	n = int(input())
	l = [int(x) for x in input().split()]
	if len(l) % 2 == 0:
		print(0)
	else:
		res = 0
		for i in range(0, n, 2):
			res ^= l[i]
		print(res)


T = int(input())
for _ in range(T):
	N = int(input())
	a = [int(ns) for ns in str(input()).split()]
	if N % 2:
		ans = a[0]
		for i in range(2, N, 2):
			ans = ans ^ a[i]
		print(ans)
	else:
		print(0)


T = int(input())
for i in range(T):
	N = int(input())
	A = [int(x) for x in input().split()]
	s = 0
	for i in range(N):
		if (N - i) * (i + 1) % 2 == 1:
			s = s ^ A[i]
	print(s)


def solve(array, n):
	result = 0
	for i in range(n):
		num_subsequences = (i + 1) * (n - i)
		if num_subsequences % 2 != 0:
			result ^= array[i]
	return result
for _ in range(int(input())):
	n = int(input())
	array = [int(x) for x in input().split()]
	print(solve(array, n))


def solve(s, n):
	res = 0
	for i in range(0, n):
		num_sub = (i + 1) * (n - i)
		if num_sub % 2 != 0:
			res ^= s[i]
	return res
for _ in range(int(input())):
	n = int(input())
	s = [int(x) for x in input().split()]
	print(solve(s, n))


T = int(input())
for i in range(T):
	input()
	l = list(map(int, input().split()))
	if len(l) % 2 is 0:
		print('0')
	else:
		r = 0
		for j in range(len(l)):
			if j % 2 is 0:
				r ^= l[j]
		print(r)


t = int(input())
for i in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	r = 0
	for (i, x) in enumerate(a):
		if (i + 1) * (n - i) % 2 != 0:
			r ^= x
	print(r)


from collections import defaultdict
T = int(input())
while T:
	N = int(input())
	if not N % 2:
		input()
		print(0)
	else:
		l = list(map(int, input().split()))[::2]
		ret = 0
		for x in l:
			ret ^= x
		print(ret)
	T -= 1


for test in range(0, int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	if len(arr) % 2 == 0:
		print(0)
	else:
		result = 0
		for i in range(len(arr)):
			if i % 2 == 0:
				result = result ^ arr[i]
		print(result)


import functools
n = int(input())
while n:
	n -= 1
	l = int(input())
	ar = list(map(int, input().strip().split()))
	if l % 2 == 0:
		print(0)
	else:
		print(functools.reduce(lambda x, y: x ^ y, [x for (i, x) in enumerate(ar) if i % 2 == 0]))


t = int(input())
for _ in range(t):
	n = int(input())
	lis = list(map(int, input().split()))
	res = 0
	for (i, x) in enumerate(lis):
		temp = (i + 1) * (n - i)
		if temp % 2:
			res = res ^ x
	print(res)


from collections import Counter

def contiguous_xor(array):
	if len(array) % 2 == 0:
		return 0
	start = 0
	result = 0
	while start < len(array):
		result ^= array[start]
		start += 2
	return result
for i in range(int(input())):
	elements = int(input())
	array = [int(x) for x in input().split()]
	print(contiguous_xor(array))


t = int(input())
for _ in range(t):
	n = int(input())
	arr = [x for x in list(map(int, input().split()))]
	xor_result = 0
	if len(arr) % 2 != 0:
		for i in range(0, len(arr), 2):
			xor_result ^= arr[i]
	print(xor_result)


numTests = int(input())
for test in range(numTests):
	arraySize = int(input())
	array = list(map(int, input().split(' ')))
	if arraySize % 2 == 0:
		print(0)
	else:
		runningXor = array[0]
		for ix in range(2, arraySize + 1, 2):
			runningXor ^= array[ix]
		print(runningXor)


import fileinput
isString = True
for line in fileinput.input():
	if fileinput.isfirstline():
		continue
	else:
		isString = not isString
		if not isString:
			continue
		seq = [int(x) for x in line.rstrip().split(' ')]
		if len(seq) & 1:
			ans = 0
			for x in range(0, len(seq), 2):
				ans ^= seq[x]
			print(ans)
		else:
			print(0)


def main():
	for _ in range(int(input())):
		N = int(input())
		A = [int(x) for x in input().split()]
		if N % 2 == 0:
			print(0)
		else:
			ans = 0
			for a in range(0, N, 2):
				ans ^= A[a]
			print(ans)
main()


import functools, operator as op, sys
T = int(sys.stdin.readline())
for _ in range(T):
	N = int(sys.stdin.readline())
	A = list(map(int, sys.stdin.readline().split()))
	print(functools.reduce(op.xor, (a for (i, a) in enumerate(A) if (i + 1) * (N - i) % 2 == 1), 0))


from functools import reduce
t = int(input())
for i in range(t):
	n = int(input())
	l = [int(j) for j in input().split()]
	if n % 2 == 0:
		print('0')
		continue
	res = []
	for j in range(0, n, 2):
		res.append(l[j])
	print(reduce(lambda x, y: x ^ y, res))


t = int(input())
for k in range(t):
	n = int(input())
	ans = 0
	num = input()
	num = num.split(' ')
	for j in range(len(num)):
		times = (j + 1) * (n - j)
		x = times % 2
		if x == 1:
			ans = ans ^ int(num[j])
	print(ans)


t = int(input())
for _ in range(t):
	n = int(input())
	l = list(map(int, input().split()))
	result = 0
	if n % 2 == 1:
		for i in range(n):
			if i % 2 == 0:
				result ^= l[i]
	print(result)


import sys
T = int(sys.stdin.readline())
for case in range(T):
	_N = sys.stdin.readline()
	xs = [int(X) for X in sys.stdin.readline().split()]
	if len(xs) % 2:
		result = 0
		for x in [x for (i, x) in enumerate(xs) if not i % 2]:
			result ^= x
		print(result)
	else:
		print(0)


def XOR(x, y, l):
	z = 0
	for i in range(x, y + 1):
		z ^= l[i]
	return z
t = int(input())
for i in range(t):
	a = []
	n = int(input())
	a = [0] * n
	l = list(map(int, input().split()))
	zor = 0
	for x in range(len(l)):
		a[x] = (x + 1) * (len(l) - x) % 2
	for index in range(len(l)):
		if a[index]:
			zor ^= l[index]
	print(zor)


def f(list):
	ix = 0
	result = 0
	for i in list:
		if ix & 1 == 0:
			result ^= i
		ix += 1
	return result
rep = int(input())
for i in range(0, rep):
	length = int(input())
	if length & 1 == 1:
		l = list(map(int, input().split()))
		print(f(l))
	else:
		l = input()
		print(0)


for i in range(int(input())):
	n = int(input())
	A = [int(i) for i in input().split()]
	if n % 2 == 0:
		print(0)
	else:
		m = n // 2 + 1
		t = 0
		for i in range(0, n, 2):
			t = t ^ A[i]
		print(t)


from functools import reduce
T = int(input())
for _ in range(T):
	N = int(input())
	inp = [int(x) for x in input().split()]
	xor = reduce(lambda x, y: x ^ y, inp[::2]) if len(inp) % 2 else 0
	print(xor)


def result(a, n):
	if n % 2 == 0:
		return 0
	answer = 0
	for i in range(0, n):
		if i % 2 == 0:
			answer ^= a[i]
	return answer

def main():
	t = int(input())
	for i in range(0, t):
		n = int(input())
		ar = input().split()
		a = []
		for j in range(0, n):
			a.append(int(ar[j]))
		print(result(a, n))
main()


T = int(input())
for t in range(T):
	n = int(input())
	s = str(input())
	r = 0
	v = s.split(' ')
	tot = 0
	for i in range(n):
		x = tot - i * (i + 1) // 2 + n - i
		tot += n - i
		if x % 2 == 1:
			r ^= int(v[i])
	print(r)


T = int(input())
for t in range(T):
	N = int(input())
	A = list(map(int, input().split()))
	if N % 2 == 0:
		print(0)
	else:
		out = 0
		for i in range(0, N, 2):
			out = out ^ A[i]
		print(out)


case = int(input())
while case > 0:
	n = int(input())
	a = list(map(int, input().split(' ')))
	if n % 2 == 0:
		x = 0
	else:
		x = a[0]
		for i in range(1, n):
			if (i + 1) % 2 != 0:
				x = x ^ a[i]
	print(x)
	case = case - 1


t = int(input())
for i in range(t):
	l = int(input())
	a = list(map(int, input().split()))
	if l % 2 == 0:
		print(0)
	else:
		b = a[0::2]
		ans = 0
		for num in b:
			ans ^= num
		print(ans)


def reduce(a):
	t = a[0]
	for elem in a[1:]:
		t ^= elem
	return t

def solve(n, a):
	final = 0
	for i in range(n):
		t = (i + 1) * (n - i)
		if t % 2 == 1:
			final ^= a[i]
	return final
for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	print(solve(n, a))


import operator
from functools import reduce
for _ in range(int(input())):
	input()
	L = [int(i) for i in input().split()]
	if len(L) % 2 == 0:
		print(0)
	else:
		print(reduce(operator.xor, L[::2]))


def solve(sz_arr, arr):
	if sz_arr % 2 == 0:
		return 0
	ret = 0
	for i in range(0, sz_arr, 2):
		if i % 2 == 0:
			ret ^= arr[i]
	return ret
for _ in range(int(input())):
	print(solve(int(input()), [int(x) for x in input().split()]))


for test in range(int(input().strip())):
	N = int(input().strip())
	arr = [int(x) for x in input().strip().split()]
	result = 0
	for i in range(N):
		if (i + 1) * (N - i) % 2 == 1:
			result ^= arr[i]
	print(result)


T = int(input())
for case in range(T):
	n = int(input())
	ar = list(map(int, input().split(' ')))
	if n % 2 == 0:
		print(0)
	else:
		res = 0
		for i in range(0, n, 2):
			res ^= ar[i]
		print(res)


ncases = int(input())
for i in range(0, ncases):
	nxs = int(input())
	xs = list(map(int, input().split()))
	if nxs % 2 == 0:
		print(0)
	else:
		total = xs[0]
		for x in range(2, nxs, 2):
			total = total ^ xs[x]
		print(total)