{"trustable":true,"prependHtml":"\u003cscript\u003e\n window.katexOptions \u003d {\n delimiters: [\n {left: \u0027\\\\(\u0027, right: \u0027\\\\)\u0027, display: false},\n ]\n };\n\u003c/script\u003e\n","sections":[{"title":"","value":{"format":"HTML","content":"\u003cp\u003e\nA number that will be the same when it is written forwards or backwards is known as a palindromic number. For example, 1234321 is a palindromic number.\n\u003c/p\u003e\n\n\u003cp\u003e\nWe call a number \u003cstrong\u003egeneralized palindromic number\u003c/strong\u003e, if after merging all the consecutive same digits, the resulting number is a palindromic number. For example, 122111 is a generalized palindromic number. Because after merging, 122111 turns into 121 which is a palindromic number.\n\u003c/p\u003e\n\n\u003cp\u003e\nNow you are given a positive integer \u003cvar\u003eN\u003c/var\u003e, please find the largest generalized palindromic number less than \u003cvar\u003eN\u003c/var\u003e.\n\u003c/p\u003e\n\n\u003ch4\u003eInput\u003c/h4\u003e\n\n\u003cp\u003eThere are multiple test cases. The first line of input contains an integer \u003cvar\u003eT\u003c/var\u003e (about 5000) indicating the number of test cases. For each test case:\u003c/p\u003e\n\n\u003cp\u003e\nThere is only one integer \u003cvar\u003eN\u003c/var\u003e (1 \u0026lt;\u003d \u003cvar\u003eN\u003c/var\u003e \u0026lt;\u003d 10\u003csup\u003e18\u003c/sup\u003e).\n\u003c/p\u003e\n\n\u003ch4\u003eOutput\u003c/h4\u003e\n\n\u003cp\u003e\nFor each test case, output the largest generalized palindromic number less than \u003cvar\u003eN\u003c/var\u003e.\n\u003c/p\u003e\n\n\u003ch4\u003eSample\u003c/h4\u003e\n\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\u003e4\n12\n123\n1224\n1122\n\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003e11\n121\n1221\n1121\n\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n\n"}}]}