Alice and Bob are playing a game on an array $$$A$$$ consisting of $$$n$$$ positive integers. Alice picks some $$$i$$$ and sets $$$A[i]$$$ to $$$A[i]$$$ $$$|$$$ $$$x$$$. Then, Bob picks some $$$j$$$ and sets $$$A[j]$$$ to $$$A[j]$$$ $$$\&$$$ $$$y$$$. Note that each player only plays one turn. The score of the game is equal to the sum of $$$A$$$.
Alice wants to minimize the score while Bob wants to maximize the score. Find the score of the game if both players play optimally.
The first line of input contains the number of testcases $$$t$$$ $$$(1 \le t \le 10^3)$$$. The description of the test cases follows.
The first line of each test case contains three positive integers $$$n$$$, $$$x$$$, and $$$y$$$ $$$(1 \le n \le 10^5$$$, $$$ 1 \le x, y \le 10^9)$$$ — the size of the array $$$A$$$ and the two integers being applied to the array.
The second line of each test case contains $$$n$$$ positive integers $$$A_1, A_2, \ldots, A_n$$$ $$$(1 \le A_i \le 10^9)$$$.
—
Tests in subtasks are numbered from $$$1−20$$$ with samples skipped. Each test is worth $$$\frac{100}{20}=5$$$ points.
Tests $$$1-4$$$ satisfy the sum of $$$n$$$ over all test cases does not exceed $$$10^3$$$.
Tests $$$5-20$$$ satisfy the sum of $$$n$$$ over all test cases does not exceed $$$10^5$$$.
For each test case, output the score of the game if both players play optimally.
54 5 21 4 3 65 6 32 5 7 1 43 3 42 3 55 536870912 268435456536870912 268435456 800000000 900000000 1234567895 2 61 3 2 4 5
14 19 9 2628763157 15
In the first test case, Alice can choose $$$i = 1$$$ so that $$$A[1] = 4|5 = 5$$$ and Bob can choose $$$j = 0$$$ so that $$$A[0] = 1\&2 = 0$$$. The resulting array $$$A = \{0, 5, 3, 6\}$$$ which leads to the optimal sum of $$$14$$$.
In the second test case, an optimal solution is Alice can choose $$$i = 2$$$ so that $$$A[2] = 7|6 = 7$$$ and Bob can choose $$$j = 0$$$ so that $$$A[0] = 2\&3 = 2$$$. The resulting array $$$A = \{2, 5, 7, 1, 4\}$$$ which leads to the optimal sum of $$$19$$$.
—
Problem Idea: HaccerKat
Problem Preparation: feining_for_gm
Occurrences: Novice D