{"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\"\u003eThe Pocket Cube, also known as the Mini Cube or the Ice Cube, is the 2 × 2 × 2 equivalence of a Rubik’s Cube.\u003cbr\u003eThe cube consists of 8 pieces, all corners.\u003cbr\u003eEach piece is labeled by a three dimensional coordinate (h, k, l) where h, k, l ∈ {0, 1}. Each of the six faces owns four small faces filled with a positive integer.\u003cbr\u003eFor each step, you can choose a certain face and turn the face ninety degrees clockwise or counterclockwise.\u003cbr\u003eYou should judge that if one can restore the pocket cube in one step. We say a pocket cube has been restored if each face owns four same integers.\u003cbr\u003e\u003c/div\u003e"}},{"title":"Input","value":{"format":"HTML","content":"The first line of input contains one integer N(N ≤ 30) which is the number of test cases.\u003cbr\u003eFor each test case, the first line describes the top face of the pocket cube, which is the common 2 × 2 face of pieces\u003cbr\u003elabelled by (0, 0, 1),(0, 1, 1),(1, 0, 1),(1, 1, 1). Four integers are given corresponding to the above pieces.\u003cbr\u003eThe second line describes the front face, the common face of (1, 0, 1),(1, 1, 1),(1, 0, 0),(1, 1, 0). Four integers are\u003cbr\u003egiven corresponding to the above pieces.\u003cbr\u003eThe third line describes the bottom face, the common face of (1, 0, 0),(1, 1, 0),(0, 0, 0),(0, 1, 0). Four integers are\u003cbr\u003egiven corresponding to the above pieces.\u003cbr\u003eThe fourth line describes the back face, the common face of (0, 0, 0),(0, 1, 0),(0, 0, 1),(0, 1, 1). Four integers are\u003cbr\u003egiven corresponding to the above pieces.\u003cbr\u003eThe fifth line describes the left face, the common face of (0, 0, 0),(0, 0, 1),(1, 0, 0),(1, 0, 1). Four integers are given\u003cbr\u003ecorresponding to the above pieces.\u003cbr\u003eThe six line describes the right face, the common face of (0, 1, 1),(0, 1, 0),(1, 1, 1),(1, 1, 0). Four integers are given\u003cbr\u003ecorresponding to the above pieces.\u003cbr\u003eIn other words, each test case contains 24 integers a, b, c to x. You can flat the surface to get the surface development\u003cbr\u003eas follows.\u003cbr\u003e\u003cpre\u003e\u003cbr\u003e+ - + - + - + - + - + - +\u003cbr\u003e| q | r | a | b | u | v |\u003cbr\u003e+ - + - + - + - + - + - +\u003cbr\u003e| s | t | c | d | w | x |\u003cbr\u003e+ - + - + - + - + - + - +\u003cbr\u003e | e | f |\u003cbr\u003e + - + - +\u003cbr\u003e | g | h |\u003cbr\u003e + - + - +\u003cbr\u003e | i | j |\u003cbr\u003e + - + - +\u003cbr\u003e | k | l |\u003cbr\u003e + - + - +\u003cbr\u003e | m | n |\u003cbr\u003e + - + - +\u003cbr\u003e | o | p |\u003cbr\u003e + - + - +\u003cbr\u003e\u003c/pre\u003e"}},{"title":"Output","value":{"format":"HTML","content":"For each test case, output YES if can be restored in one step, otherwise output NO."}},{"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\u003e4\r\n1 1 1 1\r\n2 2 2 2\r\n3 3 3 3\r\n4 4 4 4\r\n5 5 5 5\r\n6 6 6 6\r\n6 6 6 6\r\n1 1 1 1\r\n2 2 2 2\r\n3 3 3 3\r\n5 5 5 5\r\n4 4 4 4\r\n1 4 1 4\r\n2 1 2 1\r\n3 2 3 2\r\n4 3 4 3\r\n5 5 5 5\r\n6 6 6 6\r\n1 3 1 3\r\n2 4 2 4\r\n3 1 3 1\r\n4 2 4 2\r\n5 5 5 5\r\n6 6 6 6\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003eYES\r\nYES\r\nYES\r\nNO\r\n\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n"}}]}