# XxOoRr Solution | XXOORR | CODECHEF JULY CHALLENGE

Given an array A1,A2…ANA1,A2…AN, find the minimum number of operations (possibly zero) required to convert all integers in AA to 00.

In one operation, you

- choose a non-negative integer pp (p≥0p≥0),

- select at most KK indices in the array AA, and

- for each selected index ii, replace AiAi with Ai⊕2pAi⊕2p. Here, ⊕⊕ denotes bitwise XOR.

Input

- The first line contains an integer TT — the number of test cases. Then TT test cases follow.

- The first line of each test case contains two integers NN, KK — the size of the array and the maximum number of elements you can select in an operation.

- The second line of each test case contains NN integers A1,A2…ANA1,A2…AN.

Output

For each test case, output the minimum number of operations to make all elements of the array 00.

Constraints

- 1≤T≤1051≤T≤105

- 1≤N,K≤1051≤N,K≤105

- 0≤Ai≤1090≤Ai≤109

- The sum of NN over all test cases does not exceed 2⋅1052⋅105

Subtasks

- **Subtask #1 (100 points)**: Original Constraints

Sample Input

1

3 2

3 6 10

Sample Output

5

Explanation

Here is one way to achieve from in 55 operations:

- Choose p=0p=0 and indices {1}{1}. Now AA becomes .

- Choose p=1p=1 and indices {1,2}{1,2}. Now AA becomes .

- Choose p=1p=1 and indices {3}{3}. Now AA becomes .

- Choose p=2p=2 and indices {2}{2}. Now AA becomes .

- Choose p=3p=3 and indices {3}{3}. Now AA becomes .

It can be shown that at least 55 operations are required.

**SOLUTION**

Due to copyright issues we won’t be able to update the solution here immediately. However you can **download the code file from our telegram channel**. So join our telegram channel for further updates. Keep tracking, the solution will be updated on this website soon.

*Read more post** Here*