You are given a sequence of nonnegative integers. You want to make all elements of the sequence equal.
In one operation, you may choose two adjacent elements in the current sequence and replace them with the single element , where denotes bitwise XOR. This merge reduces the length of the sequence by and leaves the order of all other elements unchanged.
For example, merging the first two elements of produces , because .
Find the minimum number of merges needed to make all elements of the sequence equal. If they are already equal, the answer is . A sequence with only one element also satisfies this condition.
The input is given from Standard Input in the following format:
For each test case, print the minimum number of merges needed, on a separate line.
First test case: Merging the first two elements changes the sequence to .
Second test case: Merging the first two elements changes the sequence to . Then merging the last two elements makes the sequence .
is the number of test cases. Each test case is given in the following format:
| 2 | 33 | . |
| 3 | 11 |
|
| 4 | 47 | No additional constraints. |
Third test case: Two merge operations can reduce the sequence to one element.