logo AlgoBeat OnlineJudge
登录 注册

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

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

题目描述

Consider an array with elements. Each of its elements is (). Then two integers , are given, and queries follow. For each query, you are given , . You can get by the following rules.

To get , at first you need to choose some elements from to , we call them . Then you can get number or .

Please calculate the maximum for each query.

输入格式

Several test cases.

First line an integer (). Indicates the number of test cases. Then test cases follow. Each test case begins with three integers , , (). The next line has integers indicating to (). Then lines follow, each line contains two integers , ().

输出格式

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

样例

样例输入 1

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

样例输出 1

3
7
7