{"trustable":true,"prependHtml":"\u003cscript src\u003d\"https://acm.hdu.edu.cn/js/MathJax/MathJax/MathJax.js?config\u003dTeX-AMS-MML_HTMLorMML\" type\u003d\"text/javascript\"\u003e\u003c/script\u003e\n\u003cscript\u003e\n window.katexOptions \u003d {\n disable: true\n };\n\u003c/script\u003e\n","sections":[{"title":"","value":{"format":"HTML","content":"\u003cdiv class\u003d\"panel_content\"\u003e\n Sudoku is a logic-based, combinatorial number-placement puzzle, which is popular around the world.\n \u003cbr\u003e\n In this problem, let us focus on puzzles with $16 \\times 16$ grids, which consist of $4 \\times 4$ regions. The objective is to fill the whole grid with hexadecimal digits, i.e. 0123456789ABCDEF, so that each column, each row, and each region contains all hexadecimal digits. The figure below shows a solved sudoku.\n \u003cbr\u003e\n \u003cbr\u003e\n \u003ccenter\u003e\n \u003cimg style\u003d\"max-width:100%;\" src\u003d\"CDN_BASE_URL/2624cecc73e2ccd5603f8991bb552641?v\u003d1694922891\"\u003e\n \u003c/center\u003e\n \u003cbr\u003e\n \u003cbr\u003e\n Yesterday, Kazari solved a sudoku and left it on the desk. However, Minato played a joke with her - he performed the following operation several times.\n \u003cbr\u003e\n * Choose a region and rotate it by 90 degrees counterclockwise.\n \u003cbr\u003e\n She burst into tears as soon as she found the sudoku was broken because of rotations.\n \u003cbr\u003e\n Could you let her know how many operations her brother performed at least?\n\u003c/div\u003e"}},{"title":"Input","value":{"format":"HTML","content":"The first line of the input contains an integer $T$ $(1 \\le T \\le 10 ^ 3)$ denoting the number of test cases.\n\u003cbr\u003e\nEach test case consists of exactly $16$ lines with $16$ characters each, describing a broken sudoku.\n\u003cbr\u003e"}},{"title":"Output","value":{"format":"HTML","content":"For each test case, print a non-negative integer indicating the minimum possible number of operations.\n\u003cbr\u003e"}},{"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\n681D5A0C9FDBB2F7\r\n0A734B62E167D9E5\r\n5C9B73EF3C208410\r\nF24ED18948A5CA63 \r\n39FAED5616400B74 \r\nD120C4B7CA3DEF38 \r\n7EC829A085BE6D51 \r\nB56438F129F79C2A \r\n5C7FBC4E3D08719F \r\nAE8B1673BF42A58D \r\n60D3AF25619C30BE\r\n294190D8EA57264C \r\nC7D1B35606835EAB \r\nAF52A1E019BE4306 \r\n8B36DC78D425F7C9 \r\nE409492FC7FA18D2\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003e5\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n"}},{"title":"Hint","value":{"format":"HTML","content":"\u003cbr\u003e\nThe original sudoku is same as the example in the statement.\n\u003cbr\u003e\n\u003ccenter\u003e\n \u003cimg style\u003d\"max-width:100%;\" src\u003d\"CDN_BASE_URL/332814cd5810f178c905fa90e51bf085?v\u003d1694922891\"\u003e\n\u003c/center\u003e\n\u003cbr\u003e"}}]}