We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.

Loading...

- Practice
- Algorithms
- Bit Manipulation
- Xor-sequence

# Xor-sequence

# Xor-sequence

An array, , is defined as follows:

- for , where is the symbol for XOR

You will be given a left and right index . You must determine the XOR sum of the segment of as .

For example, . The segment from to sums to .

Print the answer to each question.

**Input Format**

The first line contains an integer , the number of questions.

Each of the next lines contains two space-separated integers, and , the inclusive left and right indexes of the segment to query.

**Constraints**

**Output Format**

On a new line for each test case, print the *XOR-Sum* of 's elements in the inclusive range between indices and .

**Sample Input 0**

```
3
2 4
2 8
5 9
```

**Sample Output 0**

```
7
9
15
```

**Explanation 0**

The beginning of our array looks like this:

*Test Case 0:*

*Test Case 1:*

*Test Case 2*: