#P1665E. MinimizOR
MinimizOR
Description
You are given an array of non-negative integers, numbered from to .
Let's define the cost of the array as , where denotes the bitwise OR operation.
There are queries. For each query you are given two integers and (). For each query you should find the cost of the subarray .
Each test case consists of several test cases. The first line contains a single integer () — the number of test cases.
The first line of each test case contains an integer () — the length array .
The second line of each test case contains integers () — the elements of .
The third line of each test case contains an integer () — the number of queries.
Each of the next lines contains two integers , () — the description of the -th query.
It is guaranteed that the sum of and the sum of over all test cases do not exceed .
For each test case print numbers, where the -th number is the cost of array .
Input
Each test case consists of several test cases. The first line contains a single integer () — the number of test cases.
The first line of each test case contains an integer () — the length array .
The second line of each test case contains integers () — the elements of .
The third line of each test case contains an integer () — the number of queries.
Each of the next lines contains two integers , () — the description of the -th query.
It is guaranteed that the sum of and the sum of over all test cases do not exceed .
Output
For each test case print numbers, where the -th number is the cost of array .
Note
In the first test case the array is
.
That's why the answers for the queries are:
- : ;
- : ;
- : ;
- : .
In the second test case the array is
().
That's why the answers for the queries are:
- : ;
- : ;
- : ;
- : .