import qualified Control.Arrow as Arrow import qualified Control.Monad as Monad import qualified Data.Char as Char import qualified Data.List as List import qualified Data.ByteString.Char8 as BSC8 import qualified Data.Vector.Unboxed as VU import qualified Data.Ord as Ord getI :: BSC8.ByteString -> Maybe (Int, BSC8.ByteString) getI = fmap (Arrow.second BSC8.tail) . BSC8.readInt getAB :: IO (Int, Int) getAB = (\vec -> (vec VU.! 0, vec VU.! 1)) . VU.unfoldrN 2 getI <$> BSC8.getLine main :: IO () main = do (n, k) <- getAB s <- BSC8.getLine if even (n - k) then solve' n k s else solve'' n k s solve', solve'' :: Int -> Int -> BSC8.ByteString -> IO () solve' n k s = BSC8.putStrLn $ BSC8.append (BSC8.drop (k - 1) s) (BSC8.reverse $ BSC8.take (k - 1) s) solve'' n k s = BSC8.putStrLn $ BSC8.append (BSC8.drop (k - 1) s) (BSC8.take (k - 1) s)