Given a binary array. Find the minimum number of swap operations to be performed such that the Bitwise of any subarray of size > 1 is equal. If it can't be done, print . Swap can be defined as interchanging array values at any two indices and .
Input:
The first line contains , the number of test cases
The first line of each test case contains , the number of elements in the array
The second line of each test case contains integers
Output:
Print lines
Each line should contain the answer for that test case
Constraints :
The sum of over all test cases does not exceed
We can swap indices 2 and 3. This way the array becomes 1 0 1 0 1 0.
Now the Bitwise AND of every subarray of size >1 is equal to 0.
It can be shown that this is the best possible answer.