{"trustable":true,"prependHtml":"\u003cscript\u003e window.katexOptions \u003d { disable: true }; \u003c/script\u003e\n\u003cscript type\u003d\"text/x-mathjax-config\"\u003e\n MathJax.Hub.Config({\n tex2jax: {\n inlineMath: [[\u0027$$$\u0027,\u0027$$$\u0027], [\u0027$\u0027,\u0027$\u0027]],\n displayMath: [[\u0027$$$$$$\u0027,\u0027$$$$$$\u0027], [\u0027$$\u0027,\u0027$$\u0027]]\n }\n });\n\u003c/script\u003e\n\u003cscript async src\u003d\"https://mathjax.codeforces.org/MathJax.js?config\u003dTeX-AMS-MML_HTMLorMML\" type\u003d\"text/javascript\"\u003e\u003c/script\u003e","sections":[{"title":"","value":{"format":"HTML","content":"\u003cdiv class\u003d\"panel_content\"\u003eLittle Bob’s computer has 2\u003csup\u003en\u003c/sup\u003e bytes of memory. For convenience, n-bit integers 0 to 2\u003csup\u003en\u003c/sup\u003e - 1 are used to index these bytes.\u003cbr\u003e\u003cbr\u003e\u003cimg style\u003d\"max-width:100%;\" src\u003d\"CDN_BASE_URL/24f0e2f68309ab06446ab6d27c5d58cc?v\u003d1725006304\"\u003e\u003cbr\u003e\u003cbr\u003eNow 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\u003csup\u003em\u003c/sup\u003e - 1 (inclusive) to a single byte.\u003cbr\u003e\u003cbr\u003eBob 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 \u0026lt; 2\u003csup\u003em\u003c/sup\u003e), the preference score for it is w\u003csub\u003ei\u003c/sub\u003e,\u003csub\u003ej\u003c/sub\u003e.\u003cbr\u003e\u003cbr\u003eIn 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\u003csub\u003ea\u003c/sub\u003e xor u\u003csub\u003eb\u003c/sub\u003e):\u003cbr\u003e\u003cbr\u003e 1.a and b only have one bit of difference in their binary forms;\u003cbr\u003e\u003cbr\u003e 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.\u003cbr\u003e\u003cbr\u003eThe total score of an assignment solution is the sum of the preference scores of all bytes plus the sum of all additional scores.\u003cbr\u003e\u003cbr\u003eBob wants to find an assignment solution with the maximum total score. If there are multiple solutions, you can output any of them.\u003c/div\u003e"}},{"title":"Input","value":{"format":"HTML","content":"The first line contains an integer T (T ≤ 3), denoting the number of the test cases.\u003cbr\u003e\u003cbr\u003eFor each test case, the first line contains two integers, n and m(1 ≤ n, m ≤ 8), as mentioned above. The second line contains 2\u003csup\u003en\u003c/sup\u003e integers, and the i-th integer is the threshold value for byte i. The threshold values are between 0 and 2\u003csup\u003em\u003c/sup\u003e - 1, inclusively. The third line contains 2\u003csup\u003en\u003c/sup\u003e integers, and the i-th integer is ui(0 ≤ u\u003csub\u003ei\u003c/sub\u003e \u0026lt; 1024). The next 2\u003csup\u003en\u003c/sup\u003e lines give all preference scores. Each line contains 2\u003csup\u003em\u003c/sup\u003e integers, and the j-th integer of the i-th line is w\u003csub\u003ei\u003c/sub\u003e,\u003csub\u003ej\u003c/sub\u003e (-1024 ≤ w\u003csub\u003ei\u003c/sub\u003e,\u003csub\u003ej\u003c/sub\u003e \u0026lt; 1024)."}},{"title":"Output","value":{"format":"HTML","content":"For each test case, output one line consisting of 2\u003csup\u003en\u003c/sup\u003e integers between 0 and 2\u003csup\u003em\u003c/sup\u003e - 1, and the i-th integer is the value assigned to byte i in the assignment solution with the maximum total score."}},{"title":"Sample","value":{"format":"HTML","content":"\u003ctable class\u003d\u0027vjudge_sample\u0027\u003e\n\u003cthead\u003e\n \u003ctr\u003e\n \u003cth\u003eInput\u003c/th\u003e\n \u003cth\u003eOutput\u003c/th\u003e\n \u003c/tr\u003e\n\u003c/thead\u003e\n\u003ctbody\u003e\n \u003ctr\u003e\n \u003ctd\u003e\u003cpre\u003e1\r\n3 2\r\n0 1 1 3 3 0 3 3\r\n4 8 8 7 0 9 2 9\r\n-9 -8 3 2\r\n-9 -6 4 1\r\n-6 -8 -5 3\r\n3 -1 -4 -1\r\n-6 -5 1 10\r\n-10 7 3 -10\r\n-3 -10 -4 -5 \r\n-2 -1 -9 1\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003e2 2 3 0 3 1 0 3\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n"}}]}