import Data.List

calc :: Integer -> Integer -> String -> String
calc n k s | n < 2 ^ (k-1) = let c = head $ firstStep s in take (fromIntegral n) $ repeat c
           | otherwise = slow n (k-1) $ take (fromIntegral n) $ firstStep s
    where slow n 0 s = s
          slow n k s = slow n (k-1) $ take (fromIntegral n) $ secondStep s

firstStep :: String -> String
firstStep s = fst $ let t = reverse s in foldl step (t, t) t
    where step :: (String, String) -> Char -> (String, String)
          step (a, b) x = let c = x:b in if c < a then (c, c) else (a, c)

secondStep :: String -> String
secondStep s = let t = s in move t (head t) t
    where move [] y t = t
          move (x:s) y t | x == y = move s y (x:t)
                         | otherwise = t

main = do
  n:k:_ <- map read . words <$> getLine :: IO [Integer]
  s <- getLine :: IO String
  putStrLn $ calc n k s
