You are given a deck of $$$n$$$ cards, each labeled with a number $$$a_i$$$. The game begins with an empty hand and an initial total score of zero.
On the $$$i$$$-th turn, you must pick up the $$$i$$$-th card with value $$$a_i$$$, then optionally discard some cards from your hand, ensuring that after this step, the bitwise XOR$$$^{[8]}$$$ of any two remaining cards in hand is a prime number$$$^{[11]}$$$. The score for this turn is the sum of the values of all cards in your hand, which is then added to the total score.
Determine the maximum possible total score after completing all $$$n$$$ turns.
Each test consists of multiple test cases. The first line contains a single integer $$$t$$$ ($$$1 \le t \le 50$$$) — the number of test cases. The description of the test cases follows.
The first line of each test case contains one integer $$$n$$$ ($$$1 \le n \le 150$$$).
The second line of each test case contains $$$n$$$ integers $$$a_1, a_2, \ldots, a_n$$$ ($$$1 \le a_i \lt 2^{20}$$$).
It is guaranteed that the sum of $$$n$$$ over all test cases does not exceed $$$150$$$.
For each test case, output one line containing a single integer — the maximum score you can get.
351 2 3 4 599 9 8 2 4 4 3 5 32323468 765165
24 103 1412101
Cards picked during their respective turns are underlined, while discarded cards are crossed out.
In the first test case, you can process the initial empty hand $$$\{\}$$$ and total score $$$0$$$ as follows: