import Data.List main = do [r,k] <- map read . words <$> getLine :: IO [Int] getLine css <- lines <$> getContents putStrLn $ unlines $ image r k css image r k = mag k . rotate r rotate 0 = id rotate 90 = map reverse . transpose rotate 180 = transpose . map reverse . transpose . map reverse rotate 270 = transpose . map reverse mag k = concatMap (\cs -> replicate k (concatMap (\c -> replicate k c) cs))