409700: GYM103688 B Lovely Fish
Description
$$$Fish$$$ is a working-class citizen, he works for company H(Heinz). One day, $$$Fish$$$ wants to know how much his coworkers like him.
After some research, $$$Fish$$$ organized the results into a string $$$S$$$
- when $$$S_{i}=1$$$, this means that the $$$i$$$th worker likes Fish.
- when $$$S_{i}=0$$$, this means that the $$$i$$$th worker dislikes Fish.
After researching,$$$Fish$$$ copied down $$$S_{l...r}$$$ as a new string $$$T$$$,and saw that there were many 0s among $$$T$$$, he became very sad. So he wished to insert some $$$1$$$ to any position of $$$T$$$ in order to make himself happier.
If the length of $$$T$$$ is $$$m$$$ after inserts,$$$Fish$$$ would become sad under either of the following two conditions:
- there exists a $$$p~(1\leq p \leq m)$$$ which the number of 0 are strictly larger than the number of 1 within $$$T_1$$$ to $$$T_p$$$.
- there exists a $$$p~(1\leq p \leq m)$$$ which the number of 0 are strictly larger than the number of 1 within $$$T_p$$$ to $$$T_m$$$.
$$$Fish$$$ also doesn't know for certain the value of $$$l$$$ and $$$r$$$, so he wants to know with $$$q$$$ possible pairs of $$$l$$$ and $$$r$$$, the least number of inserts that Fish needs to make in order to make himself happy.
InputThe first line contains two integers $$$n, q~(1 \leq n,q \leq 1,000,000)$$$ denoting the numbers of colleagues and questions.
The second line contains a string $$$S$$$.
for the next $$$q$$$ lines, each line contains two integers $$$l_i$$$, $$$r_i$$$, requesting the least number of changes if $$$T$$$=$$$S_{l...r}$$$
OutputTo reduce the impact of output time, you only need to output the $$$\texttt{XOR}$$$ of each query.
ExampleInput10 5 0001001111 1 6 1 10 5 7 4 7 4 6Output
0Note
For the example, the answers are $$$5,4,2,1,2$$$.
the possible solutions are:
000100->10101010101
0001001111->11100010101111
001->10101
1001->10101
100->10101