{"trustable":true,"prependHtml":"\u003cstyle type\u003d\"text/css\"\u003e\n div.illustration {\n float: right;\n padding-left: 20px;\n }\n div.illustration .illustration {\n width: 100%;\n border-radius: 4px;\n }\n pre {\n display: block;\n margin: 0 0 10px;\n font-size: 13px;\n line-height: 1.42857143;\n color: #333;\n word-break: break-all;\n word-wrap: break-word;\n }\n\u003c/style\u003e\n\u003cscript\u003e\n window.katexOptions \u003d {\n delimiters: [\n {left: \u0027\\\\[\u0027, right: \u0027\\\\]\u0027, display: true}\n ]\n };\n\u003c/script\u003e\n","sections":[{"title":"","value":{"format":"HTML","content":"\n \u003cp\u003eThe IT department at your school decided to change their\n password policy. Each password will have to consist of\n \u003cspan class\u003d\"tex2jax_process\"\u003e$N$\u003c/span\u003e \u003cspan class\u003d\"tex2jax_process\"\u003e$6$\u003c/span\u003e-digit numbers separated by dashes,\n where \u003cspan class\u003d\"tex2jax_process\"\u003e$N$\u003c/span\u003e will be\n determined by the phase of the moon and the weather forecast\n for the day after it will be generated.\u003c/p\u003e\n\n \u003cp\u003eYou realized that, if all of the numbers were palindromes\n (same numbers as the original ones if read backwards), you\n would have to remember a bunch of \u003cspan class\u003d\"tex2jax_process\"\u003e$3$\u003c/span\u003e-digit numbers, which did not sound\n that bad (at the time).\u003c/p\u003e\n\n \u003cp\u003eIn order to generate your password of \u003cspan class\u003d\"tex2jax_process\"\u003e$N$\u003c/span\u003e numbers, you get a list of\n \u003cspan class\u003d\"tex2jax_process\"\u003e$N$\u003c/span\u003e randomly generated\n \u003cspan class\u003d\"tex2jax_process\"\u003e$6$\u003c/span\u003e-digit numbers and find\n the palindromic number closest to them.\u003c/p\u003e\n\n \u003cp\u003eOf course, you would like to automate this process...\u003c/p\u003e\n\n \u003ch2\u003eInput\u003c/h2\u003e\n\n \u003cp\u003eThe first line of the input contains a single positive\n integer \u003cspan class\u003d\"tex2jax_process\"\u003e$N \\leq 1000$\u003c/span\u003e\n indicating the number of six-digit numbers in the input. Each\n of the next \u003cspan class\u003d\"tex2jax_process\"\u003e$N$\u003c/span\u003e lines\n contains a six-digit number without leading zeroes.\u003c/p\u003e\n\n \u003ch2\u003eOutput\u003c/h2\u003e\n\n \u003cp\u003eFor each six-digit number in the input, output another\n six-digit number that is closest to it and is also a\n palindrome. “Closest” in this context means “a number having\n the smallest absolute difference with the original number”. If\n there are two different numbers satisfying the above condition,\n output the smaller one of the two. Remember, no leading\n zeroes.\u003c/p\u003e\n\n \u003ch2\u003eSample 1\u003c/h2\u003e\u003cbody\u003e\u003ctable class\u003d\"vjudge_sample\"\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\u003e2\n123321\n123322\n\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003e123321\n123321\n\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n\u003c/body\u003e\n "}}]}