Under construction

Still being built. Things may change

Wedding

Interview

Time limit2sMemory limit1024 MB

Summary
After each arrival, departure, or XOR dance, the task is to print the total sociability of the fairies currently present.
Level

Medium5 of 10

Topics
Bit manipulation, Implementation
Solved
No attempts yet

Statement

Philip and Aurora are getting married today, and all the fairies of the Murky Marshes are invited. Aurora got a little bored and decided to watch how the fairies interact.

At the start, nn fairies are at the wedding, and Aurora numbered them from 11 to nn. Fairy number ii has a sociability aia_i, a non-negative integer.

During the observation, Aurora saw qq interesting moments. At the jj-th moment, one of three events happened:

  1. A fairy with sociability vjv_j arrives. Aurora gives her the first number that has never been used before. The first arriving fairy gets number n+1n + 1, the next one gets n+2n + 2, and so on.
  2. The fairy with number pjp_j leaves the wedding.
  3. A dance with expressiveness eje_j, a non-negative integer, is announced. After the dance, every fairy's sociability changes. If a fairy had sociability bb before the dance, it becomes b⊕ejb \oplus e_j, the bitwise XOR of bb and eje_j.

Aurora wants to know how intensely the fairies interact. After each event, she wants the total sociability of all fairies currently at the wedding. Help Aurora with this task.

Input

The first line contains two integers nn and qq, the number of fairies initially at the wedding and the number of moments (1≤n,q≤100 0001 \le n, q \le 100\,000).

The second line contains nn integers aia_i, the sociability values of the initial fairies (1≤ai≤1091 \le a_i \le 10^9).

Each of the next qq lines starts with an integer tjt_j, the event type (tj∈{1,2,3}t_j \in \{1, 2, 3\}).

  • If tj=1t_j = 1, the line contains one more integer vjv_j, the sociability of the arriving fairy (1≤vj≤1091 \le v_j \le 10^9). The arriving fairy gets the first number never used before.
  • If tj=2t_j = 2, the line contains one more integer pjp_j, meaning the fairy with number pjp_j leaves the wedding. It is guaranteed that this fairy is present at that moment.
  • If tj=3t_j = 3, the line contains one more integer eje_j, the expressiveness of the dance (1≤ej≤1091 \le e_j \le 10^9).

Output

After each event, print the total sociability of all fairies currently at the wedding.

Examples1

  1. Example 1

    Input
    6 5
    2 3 9 5 6 6
    1 3
    3 5
    2 2
    3 2
    2 7
    
    Expected output
    34
    37
    31
    27
    23