Skip to main content
Tuesday (24.11.2026) at 20:00: ALGOR Contest: Round #4 (Special Challenge) starts!

~/algor $ cat problems/bit-oraliq-xor

Range XOR queries

Medium 1000 ms 128 MB 53%
Share

$n$ integers $a_{1}, a_{2}, \ldots, a_{n}$ and $q$ queries are given. Each query gives $l$ and $r$; find $a_{l} \oplus a_{l+1} \oplus \ldots \oplus a_{r}$. Here $\oplus$ is the bitwise XOR (exclusive or) operation: a position of the binary representation gives $1$ where the bits differ and $0$ where they are equal.

XOR of the elements of a given range of the array

Input

The first line contains two positive integers: $n$ and $q$. The second line contains $n$ integers $a_{i}$ separated by spaces. Each of the next $q$ lines contains two positive integers: $l$ and $r$.

Output

For each query, one integer on a separate line.

Note

$1 \le n, q \le 10^{5}$
$0 \le a_{i} \le 10^{9}$
$1 \le l \le r \le n$

Examples

Input #1
5 3
1 2 3 4 5
1 3
2 5
4 4
Output #1
0
0
4
Input #2
3 2
7 7 7
1 2
1 3
Output #2
0
7

Sign in to submit a solution

Signing up is free and takes a minute.