{"problem":{"name":"Reversing and Concatenating","description":{"content":"Takahashi has a string $S$ of length $N$ consisting of lowercase English letters. On this string, he will perform the following operation $K$ times: *   Let $T$ be the string obtained by reversing $S","description_type":"Markdown"},"platform":"AtCoder","limit":{"time_limit":2000,"memory_limit":262144},"difficulty":"None","is_remote":true,"is_sync":true,"sync_url":null,"sign":"agc037_e"},"statements":[{"statement_type":"Markdown","content":"Takahashi has a string $S$ of length $N$ consisting of lowercase English letters. On this string, he will perform the following operation $K$ times:\n\n*   Let $T$ be the string obtained by reversing $S$, and $U$ be the string obtained by concatenating $S$ and $T$ in this order.\n*   Let $S'$ be some contiguous substring of $U$ with length $N$, and replace $S$ with $S'$.\n\nAmong the strings that can be the string $S$ after the $K$ operations, find the lexicographically smallest possible one.\n\n## Constraints\n\n*   $1 \\leq N \\leq 5000$\n*   $1 \\leq K \\leq 10^9$\n*   $|S|=N$\n*   $S$ consists of lowercase English letters.\n\n## Input\n\nInput is given from Standard Input in the following format:\n\n$N$ $K$\n$S$\n\n[samples]","is_translate":false,"language":"English"}],"meta":{"iden":"agc037_e","tags":[],"sample_group":[["5 1\nbacba","aabca\n\nWhen $S=$`bacba`, $T=$`abcab`, $U=$`bacbaabcab`, and the optimal choice of $S'$ is $S'=$`aabca`."],["10 2\nbbaabbbaab","aaaabbaabb"]],"created_at":"2026-03-03 11:01:14"}}