Zeroing the segment#335

Zeroing the segment

6 секунди
512 мегабајтова
Hard

This is a problem with graders.

For an array of positive integers of length , we define as follows:

The bitwise exclusive OR of non-negative integers and (a \oplus b) equals a non-negative integer, in which in the binary representation, there is a one at a certain position only if in the binary representations of and at this position there are different values. For example, 3_{10} \oplus 5_{10} = 0011_{2} \oplus 0101_{2} = 0110_{2} = 6_{10}.

An array of positive integers of length and queries of the form , are given. For each query, it is necessary to find f([a_l,a_{l+1},\ldots,a_r]).

Input

The first line contains three integers , , and (1 \leq n, q \leq 2 \cdot 10^5; 1 \leq t \leq 2) — the number of numbers, the number of queries, and the format of the queries, respectively.

The second line contains integers a_1, a_2, \dots, a_n (1 \leq a_i < 2^{60}) — the elements of the array .

The next lines contain two integers and (1 \leq l \leq r \leq n) — the parameters of the -th query.

The function init will be called exactly once.

If t=1, then the function askAll with all queries will be called exactly once. If t=2, then the function ask will be called exactly times.

Interaction

You need to implement the following functions:

void init(integer n, array of integers a)
  • — an integer representing the length of the array;

  • — an array of integers of length ;

  • this function does not return anything.

integer ask(integer l, integer r)
  • — an integer representing the left boundary of the query;

  • — an integer representing the right boundary of the query;

  • this function returns an integer — f([a_l,a_{l+1},\ldots,a_r]).

array of integers askAll(integer q, array of integers l, array of integers r)
  • — an integer representing the number of queries;

  • — an array of integers of length ; l_i represents the left boundary of the -th query;

  • — an array of integers of length ; r_i represents the right boundary of the -th query;

  • this function returns an array of integers; the -th number should be equal to the answer to the -th query.

Output

The grader will output integers in separate lines — the answers to the queries.

Examples

Example 1

Loading
Loading

Example 2

Loading
Loading

Scoring

  1. ( points): t=1, a_i=a_1 for 1\le i\le n;

  2. ( points): t=1, a_i \neq a_j for i \neq j;

  3. ( points): t=1, 2^m+n \le a_i<2^{m+1} for some natural ;

  4. ( points): t=1, a_i \le a_{i+1} for 1 \le i < n;

  5. ( points): t=1, n, q \le 1000;

  6. ( points): t=1, l_i=1 and r_i=i for 1\le i\le q.

  7. ( points): t=1, n, q \le 50000;

  8. ( points): t=1;

  9. ( points): t=2, n, q \le 10^5;

  10. ( points): t=2.