#P17146. [ICPC 2017 Xi'an R] XOR

    ID: 16752 Type: RemoteJudge 2000ms 512MiB Tried: 0 Accepted: 0 Difficulty: 8 Uploaded By: Tags>2017线段树线性基分块ST 表ICPC西安

[ICPC 2017 Xi'an R] XOR

题目描述

Consider an array AA with nn elements. Each of its elements is A[i]A[i] (1≤i≤n1 \le i \le n). Then two integers QQ, KK are given, and QQ queries follow. For each query, you are given LL, RR. You can get ZZ by the following rules.

To get ZZ, at first you need to choose some elements from A[L]A[L] to A[R]A[R], we call them A[i1],A[i2],…,A[it]A[i_1], A[i_2], \dots, A[i_t]. Then you can get number Z=KZ = K or $(A[i_1] \text{ xor } A[i_2] \text{ xor } \dots \text{ xor } A[i_t])$.

Please calculate the maximum ZZ for each query.

输入格式

Several test cases.

First line an integer TT (1≤T≤101 \le T \le 10). Indicates the number of test cases. Then TT test cases follow. Each test case begins with three integers NN, QQ, KK ($1 \le N \le 10000,\ 1 \le Q \le 100000,\ 0 \le K \le 100000$). The next line has NN integers indicating A[1]A[1] to A[N]A[N] (0≤A[i]≤1080 \le A[i] \le 10^8). Then QQ lines follow, each line contains two integers LL, RR (1≤L≤R≤N1 \le L \le R \le N).

输出格式

For each query, print the answer in a single line.

1
5 3 0
1 2 3 4 5
1 3
2 4
3 5
3
7
7