Nasty Operations
시간 제한1초메모리 제한2048 MB
배열과 접두사 XOR, 접미사 XOR, 그리고 그 역연산이 번갈아 주어질 때 모든 연산을 적용한 최종 배열을 출력한다.
문제
Svetozar has an array of integers. He came up with several operations on this array:
-
1: replace with the array of bitwise exclusive ORs of the prefixes of array .This means that the -th element of the array after the operation will become equal to .
-
2: replace with the array of bitwise exclusive ORs of the suffixes of array .This means that the -th element of the array after the operation will become equal to .
-
-1: perform the inverse operation to operation1.This means that the elements of the array will change in such a way that if operation
1is applied to the array afterwards, the resulting array will be the same as the one before operation-1. -
-2: perform the inverse operation to operation2.This means that the elements of the array will change in such a way that if operation
2is 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 (), denoting the number of test cases.
Then test case descriptions follow, each consisting of three lines.
The first line of a description contains two integers and (), denoting the size of the array and the number of operations, respectively.
The second line contains integers (), denoting the elements of the array.
The third line contains integers (, , , ), denoting the operations in the order of their application.
It is guaranteed that the sum of over all test cases does not exceed , and the sum of over all test cases does not exceed .
출력
For each test case, output integers on a separate line: the array after applying all the operations.