{"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":"\u003cp\u003eGiven string with N characters, your task is to transform it to a palindrome string. It\u0027s not as easy as you may think because there is a cost for this transformation!!\u003c/p\u003e\u003cp\u003eFirst you have to start from character at given position P. From your position you always have 2 options:\u003c/p\u003e\u003cp\u003e- You can move one step to the right or to the left, the cost of each movement is 1. Assume that the string is cyclic, this means if you move one step to the left you will be at position P-1 if P \u0026gt; 1 or at the last character if P \u003d 1, and if you move one step to the right you will be at position P+1 if P \u0026lt; N or at first character if P \u003d N.\u003c/p\u003e\u003cp\u003e- You can change the letter at your current position by replacing it with the next or previous one in the English alphabet (assume that the alphabet is also cyclic so ‘a’ is after ‘z’). The cost of each replacement is also 1.\u003c/p\u003e\u003cp\u003eYou should repeat that until the transformation is finished and the string is palindrome. What is the minimum cost to do that?\u003c/p\u003e"}},{"title":"Input","value":{"format":"HTML","content":"\u003cp\u003eThe first line contains the number of test cases T ( 1 \u003cspan class\u003d\"tex-span\"\u003e ≤ \u003c/span\u003e T \u003cspan class\u003d\"tex-span\"\u003e ≤ \u003c/span\u003e 100 ). Each test case contains 2 lines, the first line contains two integers ( 1 \u003cspan class\u003d\"tex-span\"\u003e ≤ \u003c/span\u003e N \u003cspan class\u003d\"tex-span\"\u003e ≤ \u003c/span\u003e 100,000) the length of string and ( 1 \u003cspan class\u003d\"tex-span\"\u003e ≤ \u003c/span\u003e P \u003cspan class\u003d\"tex-span\"\u003e ≤ \u003c/span\u003e N ) the initial position. While the second line contains a string with exactly N alphabetical characters.\u003c/p\u003e"}},{"title":"Output","value":{"format":"HTML","content":"\u003cp\u003eFor each test case output one line contains the minimum cost that is needed to change the string into a palindrome one.\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\u003e1\n8 3\naeabdaey\n\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003e8\n\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n"}},{"title":"Note","value":{"format":"HTML","content":"\u003cp\u003estart with P \u003d 3 ae(a)bdaey, move right \u003d\u0026gt; aea(b)daey, change to next \u003d\u0026gt; aea(c)daey, change to next \u003d\u0026gt; aea(d)deay, move left \u003d\u0026gt; ae(a)ddeay, move left \u003d\u0026gt; a(e)addeay, move left \u003d\u0026gt; (a)eaddeay, change to previous \u003d\u0026gt; (z)eaddeay, change to previous \u003d\u0026gt; (y)eaddeay. This costs 8 (4 movements and 4 replacements)\u003c/p\u003e"}}]}