War of XORs

All submissions for this problem are available.
###Read problems statements [Hindi](http://www.codechef.com/download/translated/SEPT18/hindi/CHEFZERO.pdf) ,[Bengali](http://www.codechef.com/download/translated/SEPT18/bengali/XORIER.pdf) , [Mandarin chinese](http://www.codechef.com/download/translated/SEPT18/mandarin/XORIER.pdf) , [Russian](http://www.codechef.com/download/translated/SEPT18/russian/XORIER.pdf) and [Vietnamese](http://www.codechef.com/download/translated/SEPT18/vietnamese/XORIER.pdf) as well. Chef is stuck at the following problem. Help him solve it! Chef has a sequence of integers $A_1, A_2, \dots, A_N$. He should find the number of pairs $(i, j)$ such that $1 \le i \lt j \le N$ and the bitwise XOR of $A_i$ and $A_j$ can be written as a sum of two (not necessarily different) prime numbers with the same parity (both odd or both even). ### 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$ spaceseprated integers $A_1, A_2, \dots, A_N$. ### Output For each test case, print a single line containing one integer — the number of valid pairs. ### Constraints  $1 \le T \le 10$  $1 \le N \le 10^5$  $1 \le A_i \le 10^6$ for each valid $i$ ### Subtasks **Subtask #1 (10 points):** $1 \le N \le 10^3$ **Subtask #2 (90 points):** original constraints ### Example Input ``` 1 5 2 4 8 1 3 ``` ### Example Output ``` 3 ``` ### Explanation **Example case 1:** The three valid pairs are $(1, 2)$, $(1, 3)$ and $(2, 3)$. For example, $A_1 \oplus A_2 = 2 \oplus 4 = 6 = 3+3$.Author:  priyanshi_ 
Editorial  https://discuss.codechef.com/problems/XORIER 
Tags  easy, observations, priyanshi_, sept18, xor 
Date Added:  23082018 
Time Limit:  1 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. 