Nasty Operations

시간 제한1초메모리 제한2048 MB

문제

Svetozar has an array $a$ of $n$ integers. He came up with several operations on this array:

  • 1: replace $a$ with the array of bitwise exclusive ORs of the prefixes of array $a$.

    This means that the $i$-th element of the array after the operation will become equal to $a_1 \oplus a_2 \oplus \ldots \oplus a_i$.

  • 2: replace $a$ with the array of bitwise exclusive ORs of the suffixes of array $a$.

    This means that the $i$-th element of the array after the operation will become equal to $a_i \oplus a_{i + 1} \oplus \ldots \oplus a_n$.

  • -1: perform the inverse operation to operation 1.

    This means that the elements of the array will change in such a way that if operation 1 is applied to the array afterwards, the resulting array will be the same as the one before operation -1.

  • -2: perform the inverse operation to operation 2.

    This means that the elements of the array will change in such a way that if operation 2 is applied to the array afterwards, the resulting array will be the same as the one before operation -2.

Svetozar has performed a number of operations and now asks you to check the correctness of his calculations. To simplify the verification, the first operation performed by Svetozar is always denoted by a positive number, and any two consecutive operations are denoted by numbers with different signs.

입력

The first line contains a single integer $T$ ($1 \leq T \leq 10^5$), denoting the number of test cases.

Then $T$ test case descriptions follow, each consisting of three lines.

The first line of a description contains two integers $n$ and $q$ ($1 \leq n, q \leq 10^5$), denoting the size of the array and the number of operations, respectively.

The second line contains $n$ integers $a_1, a_2, \ldots, a_n$ ($0 \leq a_i \leq 10^9$), denoting the elements of the array.

The third line contains $q$ integers $op_1, op_2, \ldots, op_q$ ($-2 \leq op_i \leq 2$, $op_i \ne 0$, $op_1 > 0$, $op_i \cdot op_{i + 1} < 0$), denoting the operations in the order of their application.

It is guaranteed that the sum of $n$ over all test cases does not exceed $10^5$, and the sum of $q$ over all test cases does not exceed $10^5$.

출력

For each test case, output $n$ integers on a separate line: the array after applying all the operations.