{"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\"\u003eXiaoqiang entered the “shortest code” challenge organized by some self-claimed astrologists. He was given a boolean function taking n inputs (in C++):\u003cbr\u003e\u003cbr\u003e\u003cb\u003ebool f(bool x1, bool x2, bool x3){\u003cbr\u003e//your code goes here\u003cbr\u003e//return something\u003cbr\u003e}\u003c/b\u003e\u003cbr\u003e\u003cbr\u003eAll possible inputs and expected outputs of this function have been revealed:\u003cbr\u003e\u003cbr\u003e\u003cimg style\u003d\"max-width:100%;\" src\u003d\"CDN_BASE_URL/170584f1b89a8501ab943240402bc512?v\u003d1725624834\"\u003e\u003cbr\u003e\u003cbr\u003eXiaoqiang’s code must be like:\u003cbr\u003e\u003cbr\u003e\u003cb\u003ebool a \u003d NAND(b, c);\u003c/b\u003e\u003cbr\u003e\u003cbr\u003ewhere “a” is a newly defined variable,“b” and “c” can be a constant (0/1) or a function parameter (x1/x2/x3) or a previously defined variable. NAND is the “not-and” function:\u003cbr\u003e\u003cbr\u003e\u003cb\u003eNAND(b, c)\u003d!(b\u0026amp;\u0026amp;c)\u003c/b\u003e\u003cbr\u003e\u003cbr\u003eBecause NAND is universal, Xiaoqiang knew that he could implement any boolean function he liked. Also, at the end of the code there should be a return statement:\u003cbr\u003e\u003cbr\u003e\u003cb\u003ereturn y;\u003c/b\u003e\u003cbr\u003e\u003cbr\u003ewhere y can be a constant or a function parameter or a previously defined variable. After staring at the function for a while, Xiaoqiang came up with the answer: \u003cbr\u003e\u003cbr\u003e\u003cb\u003ebool a \u003d NAND(x1, x2);\u003cbr\u003ebool b \u003d NAND(x2, x3);\u003cbr\u003ebool y \u003d NAND(a, b); return y;\u003c/b\u003e\u003cbr\u003e\u003cbr\u003eXiaoqiang wants to make sure that his solution is the shortest possible. Can you help him?\u003c/div\u003e"}},{"title":"Input","value":{"format":"HTML","content":"The first line contains an integer T (T ≤ 20) denoting the number of the test cases.\u003cbr\u003e\u003cbr\u003eFor each test case, there is one line containing 8 characters encoding the truth table of the function."}},{"title":"Output","value":{"format":"HTML","content":"For each test case, output a single line containing the minimum number of lines Xiaoqiang has to write."}},{"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\n00010011\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003e4\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":"Due to the small input domain, you can solve all the cases on your computer and submit a program with a table of all the answers."}}]}