{"trustable":true,"prependHtml":"\u003cstyle type\u003d\u0027text/css\u0027\u003e\n .input, .output {\n border: 1px solid #888888;\n }\n .output {\n margin-bottom: 1em;\n position: relative;\n top: -1px;\n }\n .output pre, .input pre {\n background-color: #EFEFEF;\n line-height: 1.25em;\n margin: 0;\n padding: 0.25em;\n }\n \u003c/style\u003e\n \u003clink rel\u003d\"stylesheet\" href\u003d\"//codeforces.org/s/96598/css/problem-statement.css\" type\u003d\"text/css\" /\u003e\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 type\u003d\"text/javascript\" async src\u003d\"https://mathjax.codeforces.org/MathJax.js?config\u003dTeX-AMS_HTML-full\"\u003e\u003c/script\u003e","sections":[{"title":"","value":{"format":"HTML","content":"\u003ccenter\u003e \u003cimg class\u003d\"tex-graphics\" src\u003d\"CDN_BASE_URL/9037eaa5e5083fbe4a4fa0557b3f071e?v\u003d1714108525\" style\u003d\"max-width: 100.0%;max-height: 100.0%;\"\u003e \u003c/center\u003e\u003cp\u003ePor Costel the pig, our programmer in-training, has recently returned from the Petrozaporksk training camp. There, he learned a lot of things: how to boil a cob, how to scratch his belly using his keyboard, etc... He almost remembers a programming problem too:\u003c/p\u003e\u003cp\u003eA semipalindrome is a word \u003cimg align\u003d\"middle\" class\u003d\"tex-formula\" src\u003d\"CDN_BASE_URL/c37c00d9c4013f1a59602429da53f1c3?v\u003d1714108525\" style\u003d\"max-width: 100.0%;max-height: 100.0%;\"\u003e for which there exists a subword \u003cimg align\u003d\"middle\" class\u003d\"tex-formula\" src\u003d\"CDN_BASE_URL/c7fc41c36a58c625407d0fb0ae528c62?v\u003d1714108525\" style\u003d\"max-width: 100.0%;max-height: 100.0%;\"\u003e such that \u003cimg align\u003d\"middle\" class\u003d\"tex-formula\" src\u003d\"CDN_BASE_URL/c7fc41c36a58c625407d0fb0ae528c62?v\u003d1714108525\" style\u003d\"max-width: 100.0%;max-height: 100.0%;\"\u003e is a prefix of \u003cimg align\u003d\"middle\" class\u003d\"tex-formula\" src\u003d\"CDN_BASE_URL/c37c00d9c4013f1a59602429da53f1c3?v\u003d1714108525\" style\u003d\"max-width: 100.0%;max-height: 100.0%;\"\u003e and \u003cimg align\u003d\"middle\" class\u003d\"tex-formula\" src\u003d\"CDN_BASE_URL/75616f9dedf39748940aeacd4e26622e?v\u003d1714108525\" style\u003d\"max-width: 100.0%;max-height: 100.0%;\"\u003e (reverse \u003cimg align\u003d\"middle\" class\u003d\"tex-formula\" src\u003d\"CDN_BASE_URL/c7fc41c36a58c625407d0fb0ae528c62?v\u003d1714108525\" style\u003d\"max-width: 100.0%;max-height: 100.0%;\"\u003e) is a suffix of \u003cimg align\u003d\"middle\" class\u003d\"tex-formula\" src\u003d\"CDN_BASE_URL/c37c00d9c4013f1a59602429da53f1c3?v\u003d1714108525\" style\u003d\"max-width: 100.0%;max-height: 100.0%;\"\u003e. For example, \u003cspan class\u003d\"tex-font-style-tt\"\u003e\u0027ababba\u0027\u003c/span\u003e is a semipalindrom because the subword \u003cspan class\u003d\"tex-font-style-tt\"\u003e\u0027ab\u0027\u003c/span\u003e is prefix of \u003cspan class\u003d\"tex-font-style-tt\"\u003e\u0027ababba\u0027\u003c/span\u003e and \u003cspan class\u003d\"tex-font-style-tt\"\u003e\u0027ba\u0027\u003c/span\u003e is suffix of \u003cspan class\u003d\"tex-font-style-tt\"\u003e\u0027ababba\u0027\u003c/span\u003e.\u003c/p\u003e\u003cp\u003eLet\u0027s consider only semipalindromes that contain letters \u003cspan class\u003d\"tex-font-style-tt\"\u003e\u0027a\u0027\u003c/span\u003e and \u003cspan class\u003d\"tex-font-style-tt\"\u003e\u0027b\u0027\u003c/span\u003e. You have to find the \u003cimg align\u003d\"middle\" class\u003d\"tex-formula\" src\u003d\"CDN_BASE_URL/a77df42f629c3508c7e120bb54faf181?v\u003d1714108525\" style\u003d\"max-width: 100.0%;max-height: 100.0%;\"\u003e-th lexicographical semipalindrome of length \u003cimg align\u003d\"middle\" class\u003d\"tex-formula\" src\u003d\"CDN_BASE_URL/a8b19e9d491cb38bd05246fac15e139d?v\u003d1714108525\" style\u003d\"max-width: 100.0%;max-height: 100.0%;\"\u003e.\u003c/p\u003e\u003cp\u003ePor Costel doesn\u0027t remember if the statement was exactly like this at Petrozaporksk, but he finds this problem interesting enough and needs your help to solve it.\u003c/p\u003e"}},{"title":"Input","value":{"format":"HTML","content":"\u003cp\u003eOn the first line of the file \u003cspan class\u003d\"tex-font-style-bf\"\u003esemipal.in\u003c/span\u003e, there is an integer \u003cimg align\u003d\"middle\" class\u003d\"tex-formula\" src\u003d\"CDN_BASE_URL/bfd224968ce516f58bc4320c2b68776f?v\u003d1714108525\" style\u003d\"max-width: 100.0%;max-height: 100.0%;\"\u003e (\u003cimg align\u003d\"middle\" class\u003d\"tex-formula\" src\u003d\"CDN_BASE_URL/39780ec1fee0a55bf61170a0377649c0?v\u003d1714108525\" style\u003d\"max-width: 100.0%;max-height: 100.0%;\"\u003e) representing the number of test cases. On the next \u003cimg align\u003d\"middle\" class\u003d\"tex-formula\" src\u003d\"CDN_BASE_URL/bfd224968ce516f58bc4320c2b68776f?v\u003d1714108525\" style\u003d\"max-width: 100.0%;max-height: 100.0%;\"\u003e lines there are 2 numbers, \u003cimg align\u003d\"middle\" class\u003d\"tex-formula\" src\u003d\"CDN_BASE_URL/991f81a208dc8412840eaec877974cb3?v\u003d1714108525\" style\u003d\"max-width: 100.0%;max-height: 100.0%;\"\u003e (\u003cimg align\u003d\"middle\" class\u003d\"tex-formula\" src\u003d\"CDN_BASE_URL/a5002b751aa4c97b57c89cf57ba2e895?v\u003d1714108525\" style\u003d\"max-width: 100.0%;max-height: 100.0%;\"\u003e and K \u003cimg align\u003d\"middle\" class\u003d\"tex-formula\" src\u003d\"CDN_BASE_URL/68f1f8edaab04476cc35764cc3623ca0?v\u003d1714108525\" style\u003d\"max-width: 100.0%;max-height: 100.0%;\"\u003e where \u003cimg align\u003d\"middle\" class\u003d\"tex-formula\" src\u003d\"CDN_BASE_URL/583c30a8ec704fb33c95f0715dced94c?v\u003d1714108525\" style\u003d\"max-width: 100.0%;max-height: 100.0%;\"\u003e is the number of semipalindromes of length \u003cimg align\u003d\"middle\" class\u003d\"tex-formula\" src\u003d\"CDN_BASE_URL/991f81a208dc8412840eaec877974cb3?v\u003d1714108525\" style\u003d\"max-width: 100.0%;max-height: 100.0%;\"\u003e.\u003c/p\u003e"}},{"title":"Output","value":{"format":"HTML","content":"\u003cp\u003eIn the output file \u003cspan class\u003d\"tex-font-style-bf\"\u003esemipal.out\u003c/span\u003e, there should be \u003cimg align\u003d\"middle\" class\u003d\"tex-formula\" src\u003d\"CDN_BASE_URL/bfd224968ce516f58bc4320c2b68776f?v\u003d1714108525\" style\u003d\"max-width: 100.0%;max-height: 100.0%;\"\u003e lines, the \u003cimg align\u003d\"middle\" class\u003d\"tex-formula\" src\u003d\"CDN_BASE_URL/00fe2f3abc32471332aa4477c66d0911?v\u003d1714108525\" style\u003d\"max-width: 100.0%;max-height: 100.0%;\"\u003e-th of which should contain the answer for the \u003cimg align\u003d\"middle\" class\u003d\"tex-formula\" src\u003d\"CDN_BASE_URL/00fe2f3abc32471332aa4477c66d0911?v\u003d1714108525\" style\u003d\"max-width: 100.0%;max-height: 100.0%;\"\u003e-th test.\u003c/p\u003e"}},{"title":"Examples","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\u003e2\n5 1\n5 14\n\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003eaaaaa\nbbabb\n\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n"}}]}