XrkArul has finished learning bitwise operations and he wants to do some practice. He finds an array a of length n, and intends to perform Q bitwise operations. Each operation is given as follows:
AND x. XrkArul change ai to (ai & x) for each i ∈ [1,n].
OR x. XrkArul change ai to (ai | x) for each i ∈ [1,n].
XOR x. XrkArul change ai to (ai ^ x) for each i ∈ [1,n].
Now XrkArul has quickly calculated the answers, and he wants to verify whether his answer is correct. Please help him.
The first line contains two integers n,Q ( 1 ≤ n,Q ≤ 3e5 ).
The second line contains n integers a1,a2,...,an (0 ≤ ai ≤ 230−1).
Then,Q lines follow. Each line contains a string OP (OP∈{AND,OR,XOR}) and an integer x (0 ≤ x ≤ 230−1).
Print a single line contains integers. The result of array after doing bitwise operations.
5 3 1 2 3 4 5 AND 3 OR 5 XOR 6
3 1 1 3 3