logo AlgoBeat OnlineJudge
登录 注册

#217103. [ICPC 2017 Xi'an R] Sum of xor sum

内存限制:512 MiB 时间限制:2000 ms 标准输入输出
题目类型:VJudge(洛谷) 评测方式:VJudge
上传者: 匿名

题目描述

Song Zha Zha has an -indexed array . Li Zha Zha has queries. Each query has two integers , , asking Ran Zha Zha to do the following thing: First, find all subintervals of . Then calculate their XOR sum. For example:

, , .

All subintervals of are . Their XOR sum is .

XOR means exclusive or (^ in C++ or Java).

输入格式

The input contains multiple test cases.

First line contains an integer , which is the number of test cases.

In each test case:

The first line contains two integers , . . is the length of the array .

Then one line contains integers indicating . .

Then lines follow. Each line has two integers , meaning that there’s a query . .

输出格式

For each query, print the answer mod .

样例

样例输入 1

1
3 1
1 2 3
1 3

样例输出 1

10