

MemoryTime Limit: 8000/4000 MS (Java/Others) Memory Limit: 262144/262144 K (Java/Others)Total Submission(s): 562 Accepted Submission(s): 171 Special Judge Problem Description Little Bob¡¯s computer has 2^{n} bytes of memory. For convenience, nbit integers 0 to 2^{n}  1 are used to index these bytes. Now he wants to assign a value to each byte of the memory. In this problem, a byte is composed of m bits. Therefore he can only assign 0 to 2^{m}  1 (inclusive) to a single byte. Bob has some preferences on which value to be assigned to each byte. For the byte indexed by i, if it is assigned with value j (0 ¡Ü j < 2^{m}), the preference score for it is w_{i},_{j}. In addition, each byte has a threshold value. For two different bytes indexed by a and b, if the following two conditions are satisfied, there will be an additional score (u_{a} xor u_{b}): 1.a and b only have one bit of difference in their binary forms; 2.The assigned value of byte a is not less than its threshold value, or the assigned value of byte b is not less than its threshold value. The total score of an assignment solution is the sum of the preference scores of all bytes plus the sum of all additional scores. Bob wants to find an assignment solution with the maximum total score. If there are multiple solutions, you can output any of them. Input The first line contains an integer T (T ¡Ü 3), denoting the number of the test cases. For each test case, the first line contains two integers, n and m(1 ¡Ü n, m ¡Ü 8), as mentioned above. The second line contains 2^{n} integers, and the ith integer is the threshold value for byte i. The threshold values are between 0 and 2^{m}  1, inclusively. The third line contains 2^{n} integers, and the ith integer is ui(0 ¡Ü u_{i} < 1024). The next 2^{n} lines give all preference scores. Each line contains 2^{m} integers, and the jth integer of the ith line is w_{i},_{j} (1024 ¡Ü w_{i},_{j} < 1024). Output For each test case, output one line consisting of 2^{n} integers between 0 and 2^{m}  1, and the ith integer is the value assigned to byte i in the assignment solution with the maximum total score. Sample Input
Sample Output
Source  
