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

    ID: 19430 远端评测题 2000ms 512MiB 尝试: 0 已通过: 0 显示难度普及+/提高− 上传者: 标签>2017前缀和位运算ICPC西安

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

Problem Description

Song Zha Zha has an 11-indexed array AA. Li Zha Zha has QQ queries. Each query has two integers LL, RR, asking Ran Zha Zha to do the following thing: First, find all subintervals of [L,R][L, R]. Then calculate their XOR sum. For example:

A={1,2,3}A = \{1, 2, 3\}, L=1L = 1, R=3R = 3.

All subintervals of [1,3][1, 3] are [1,1],[2,2],[3,3],[1,2],[2,3],[1,3][1, 1], [2, 2], [3, 3], [1, 2], [2, 3], [1, 3]. Their XOR sum is $1 + 2 + 3 + (1 \oplus 2)+ (2 \oplus 3) + (1 \oplus 2 \oplus 3)$.

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

Input Format

The input contains multiple test cases.

First line contains an integer TT (1T10)(1 \le T \le 10), which is the number of test cases.

In each test case:

The first line contains two integers NN, QQ. (1N,Q100000)(1 \le N, Q \le 100000). NN is the length of the array AA.

Then one line contains NN integers indicating A[i]A[i]. (1iN,0A[i]1000000)(1 \le i \le N, 0 \le A[i] \le 1000000).

Then QQ lines follow. Each line has two integers L,RL, R, meaning that there’s a query [L,R][L, R]. (1LRN)(1 \le L \le R \le N).

Output Format

For each query, print the answer mod 10000000071000000007.

1
3 1
1 2 3
1 3
10