Xor Again

All submissions for this problem are available.
Read problems statements in Mandarin chinese, Russian and Vietnamese as well.
Chef recently discovered a function $XOR()$, which computes the XOR of all elements of a sequence: $$XOR(a_{1..n}) = a_1 \oplus a_2 \oplus \dots \oplus a_n\,.$$ Chef has a sequence $A$ with size $N$. He generated a new sequence $B$ with size $N^2$ using the following formula: $$B_{iN+j+1} = (A_{i+1} + A_{j+1}) \quad \forall\; 0 \le i, j \lt N\,.$$ Compute the value of $XOR(B)$. ### Input  The first line of the input contains a single integer $T$ denoting the number of test cases. The description of $T$ test cases follows.  The first line of each test case contains a single integer $N$.  The second line contains $N$ spaceseparated integers $A_1, A_2, \dots, A_N$. ### Output For each test case, print a single line containing one integer — the answer to the problem. ### Constraints  $1 \le T \le 100$  $1 \le N \le 10^5$  $2^0 \le A_i \lt 2^{30}$ for each valid $i$ ### Subtasks **Subtask #1 (30 points):**  $1 \le N \le 500$  $2^0 \le A_i \lt 2^{10}$ for each valid $i$ **Subtask #2 (70 points):** $1 \le N \le 10^5$ ### Example Input ``` 1 2 1 2 ``` ### Example Output ``` 6 ``` ### Explanation **Example case 1:** The sequence $B$ is $\{A_1 + A_1, A_1 + A_2, A_2 + A_1, A_2 + A_2\} = \{2, 3, 3, 4\}$. The XOR of its elements is $B_1 \oplus B_2 \oplus B_3 \oplus B_4 = 6$.Author:  deadcode4 
Editorial  https://discuss.codechef.com/problems/XORAGN 
Tags  deadcode4, easy, may18, xor 
Date Added:  3042018 
Time Limit:  2 sec 
Source Limit:  50000 Bytes 
Languages:  C, CPP14, JAVA, PYTH, PYTH 3.6, PYPY, CS2, PAS fpc, PAS gpc, RUBY, PHP, GO, NODEJS, HASK, rust, SCALA, swift, D, PERL, FORT, WSPC, ADA, CAML, ICK, BF, ASM, CLPS, PRLG, ICON, SCM qobi, PIKE, ST, NICE, LUA, BASH, NEM, LISP sbcl, LISP clisp, SCM guile, JS, ERL, TCL, kotlin, PERL6, TEXT, SCM chicken, PYP3, CLOJ, COB, FS 
Comments
 Please login at the top to post a comment.
SUCCESSFUL SUBMISSIONS
Fetching successful submissions
HELP
If you are still having problems, see a sample solution here. 