XOR

Time limit2sMemory limit512 MB

Summary
Maintain an array under range XOR updates and point queries, printing each queried element in order.
Level

Medium6 of 10

Topics
Binary search, Prefix sum, Bit manipulation, Sorting
Solved
No attempts yet

Problem

Process two kinds of operations on a single sequence.

  • XOR cc into every element of the interval [a,b][a, b].
  • Print the value of the element at index aa.

Given the initial sequence and the list of operations, produce the result of every print operation in order.

Input

The first line contains the length of the sequence nn. (0<n≤500,0000 < n \le 500{,}000)

The second line contains the elements of the sequence, from index 00 to index n−1n - 1 in order. Every element is a non-negative integer no larger than 100,000100{,}000.

The third line contains the number of queries mm. (0<m≤500,0000 < m \le 500{,}000)

Each of the next mm lines holds one query and starts with the query kind tt. If tt is 1, then aa, bb, and cc follow, and cc is xored into every element of the interval [a,b][a, b]. (0≤a≤b<n0 \le a \le b < n, 0≤c≤100,0000 \le c \le 100{,}000) If tt is 2, then aa follows, and the current value of the element at index aa is printed. (0≤a<n0 \le a < n)

Output

For every query with tt equal to 2, print the current value of the element at index aa on its own line.

Examples6

  1. Example 1

    Input
    5
    1 2 3 4 5
    6
    1 0 4 9
    2 0
    2 1
    2 2
    2 3
    2 4
    
    Expected output
    8
    11
    10
    13
    12
    
  2. Example 2

    Input
    1
    0
    5
    2 0
    1 0 0 100000
    2 0
    1 0 0 100000
    2 0
    
    Expected output
    0
    100000
    0
    
  3. Example 3

    Input
    4
    7 0 100000 13
    4
    2 0
    2 1
    2 2
    2 3
    
    Expected output
    7
    0
    100000
    13
    
  4. Example 4

    Input
    6
    0 0 0 0 0 0
    9
    1 0 5 12
    1 1 3 0
    2 0
    1 2 4 5
    2 2
    2 3
    2 4
    2 5
    2 1
    
    Expected output
    12
    9
    9
    9
    12
    12
    
  5. Example 5

    Input
    3
    100000 100000 99999
    7
    1 0 2 100000
    2 0
    2 1
    2 2
    1 1 1 65535
    2 1
    2 2
    
    Expected output
    0
    0
    63
    65535
    63
    
  6. Example 6

    Input
    5
    1 2 3 4 5
    8
    1 0 4 7
    1 0 4 7
    2 0
    2 4
    1 0 0 1
    1 4 4 2
    2 0
    2 4
    
    Expected output
    1
    5
    0
    7