Problem: You are given an array of integers .
You have to answer independent queries, each consisting of two integers and .
- Consider the subarray . You can apply the following operation to the subarray any number of times (possibly zero)- Choose two integers , such that and is odd. Replace each element in the subarray from to with the XOR of the elements in the subarray .
- The answer to the query is the minimum number of operations required to make all elements of the subarray equal to or if it is impossible to make all of them equal to .
You can find more details about XOR operation here.
Input Format: The first line contains two integers and — the length of the array and the number of queries.
The next line contains integers — the elements of the array .
The -th of the next lines contains two integers and — the description of the -th query.
Output Format: For each query, output a single integer — the answer to that query.
Note: In the first query, , subarray = . We can apply operation only to the subarrays of length , which won't change the array; hence it is impossible to make all elements equal to .
In the second query, , subarray = . We can choose the whole subarray and replace all elements by their XOR , making the subarray .
In the fifth query, , subarray = . We can make the operations as follows:
- Choose , making the subarray .
- Choose , making the subarray .