{"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\u003eJohn likes simple ciphers. He had been using the “Caesar”\n cipher to encrypt his diary until recently, when he learned a\n hard lesson about its strength by catching his sister Mary\n browsing through the diary without any problems.\u003c/p\u003e\n \u003cp\u003eRapidly searching for an alternative, John found a solution:\n the famous “Autokey” cipher. He uses a version that takes the\n \u003cspan class\u003d\"tex2jax_process\"\u003e$26$\u003c/span\u003e lower-case letters\n ‘\u003ctt class\u003d\"ttfamily\"\u003ea\u003c/tt\u003e’–‘\u003ctt class\u003d\"ttfamily\"\u003ez\u003c/tt\u003e’ and\n internally translates them in alphabetical order to the numbers\n \u003cspan class\u003d\"tex2jax_process\"\u003e$0$\u003c/span\u003e to \u003cspan class\u003d\"tex2jax_process\"\u003e$25$\u003c/span\u003e.\u003c/p\u003e\n \u003cp\u003eThe encryption key \u003cspan class\u003d\"tex2jax_process\"\u003e$k$\u003c/span\u003e\n begins with a secret prefix of \u003cspan class\u003d\"tex2jax_process\"\u003e$n$\u003c/span\u003e letters. Each of the remaining\n letters of the key is copied from the letters of the plaintext\n \u003cspan class\u003d\"tex2jax_process\"\u003e$a$\u003c/span\u003e, so that \u003cspan class\u003d\"tex2jax_process\"\u003e$k_{n+i} \u003d a_{i}$\u003c/span\u003e for \u003cspan class\u003d\"tex2jax_process\"\u003e$i \\geq 1$\u003c/span\u003e. Encryption of the\n plaintext \u003cspan class\u003d\"tex2jax_process\"\u003e$a$\u003c/span\u003e to the\n ciphertext \u003cspan class\u003d\"tex2jax_process\"\u003e$b$\u003c/span\u003e follows the\n formula \u003cspan class\u003d\"tex2jax_process\"\u003e$b_ i \u003d a_ i + k_ i \\bmod\n 26$\u003c/span\u003e.\u003c/p\u003e\n \u003cp\u003eMary is not easily discouraged. She was able to get a peek\n at the last \u003cspan class\u003d\"tex2jax_process\"\u003e$n$\u003c/span\u003e letters\n John typed into his diary on the family computer before he\n noticed her, quickly encrypted the text document with a click,\n and left. This could be her chance.\u003c/p\u003e\n \u003ch2\u003eInput\u003c/h2\u003e\n \u003cp\u003eThe input consists of:\u003c/p\u003e\n \u003cul class\u003d\"itemize\"\u003e\n \u003cli\u003e\n \u003cp\u003eOne line with two integers \u003cspan class\u003d\"tex2jax_process\"\u003e$n$\u003c/span\u003e and \u003cspan class\u003d\"tex2jax_process\"\u003e$m$\u003c/span\u003e (\u003cspan class\u003d\"tex2jax_process\"\u003e$1 \\le n \\le 30$\u003c/span\u003e, \u003cspan class\u003d\"tex2jax_process\"\u003e$n + 1 \\le m \\le 100$\u003c/span\u003e), where\n \u003cspan class\u003d\"tex2jax_process\"\u003e$n$\u003c/span\u003e is the length of\n the keyword as well as the number of letters Mary saw, and\n \u003cspan class\u003d\"tex2jax_process\"\u003e$m$\u003c/span\u003e is the length of\n the text.\u003c/p\u003e\n \u003c/li\u003e\n \u003cli\u003e\n \u003cp\u003eOne line with \u003cspan class\u003d\"tex2jax_process\"\u003e$n$\u003c/span\u003e\n lower-case letters, the last \u003cspan class\u003d\"tex2jax_process\"\u003e$n$\u003c/span\u003e letters of the plaintext.\u003c/p\u003e\n \u003c/li\u003e\n \u003cli\u003e\n \u003cp\u003eOne line with \u003cspan class\u003d\"tex2jax_process\"\u003e$m$\u003c/span\u003e\n lower-case letters, the whole ciphertext.\u003c/p\u003e\n \u003c/li\u003e\n \u003c/ul\u003e\n \u003ch2\u003eOutput\u003c/h2\u003e\n \u003cp\u003eOutput the plaintext of John’s diary.\u003c/p\u003e\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\u003e5 16\nagain\npirpumsemoystoal\n\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003emarywasnosyagain\n\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n\u003c/body\u003e\n \u003ch2\u003eSample 2\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\u003e1 12\nd\nfzvfkdocukfu\n\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003eshortkeyword\n\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n\u003c/body\u003e\n "}}]}