Guess the Data Structure

아직 제출이 없습니다시간 제한5초메모리 제한256 MB

문제

You are given an array AA consisting of nn integers. All its elements are numbered with consecutive integers from 11 to nn. Your task is to process mm queries. Each of these queries is one of the following kinds:

  1. Append integer x_jx\_{j} to the end of the array AA.
  2. Output the value of _i=l_jr_jA_i\sum\_{i = l\_{j}}^{r\_{j}} A\_{i} (l_jr_jl\_{j} \leq r\_{j}).
  3. Perform A_i=A_ix_jA\_{i} = A\_{i} \oplus x\_{j} for each element of the array AA. Expression A_ix_jA\_{i} \oplus x\_{j} means applying the operation of bitwise exclusive "OR" to numbers A_iA\_{i} and x_jx\_{j}.
  4. Sort the array AA.

Your task is to implement a proper data structure to process mm given queries for a given array AA.

입력

First line of input contains the only integer nn --- the initial size of the array AA (1n21051 \leq n \leq 2 \cdot 10^{5}).

Second line of input contains nn non-negative integers A_iA\_{i} --- elements of the array AA (0A_i1090 \leq A\_{i} \leq 10^{9}).

Third line of input contains the only integer mm --- the number of queries (1m21051 \leq m \leq 2 \cdot 10^{5}).

Each of the following lines contains a separate query in the following format:

  • For the first kind of query:  "11 x_jx\_{j}"
  • For the second kind of query:  "22 l_jl\_{j} r_jr\_{j}"
  • For the third kind of query:  "33 x_jx\_{j}"
  • For the fourth kind of query:  "44"

For any query of the first or the third kind 0x_j1090 \leq x\_{j} \leq 10^{9}. For any query of the second kind l_jl\_{j} and r_jr\_{j} do not violate bounds of the array AA.

You may assume that at least one query in each test case is of the second kind.

출력

For each query of the second kind output its resulting sum on a separate line.