{-# LANGUAGE FlexibleContexts, OverloadedStrings #-} import Control.Applicative import Control.Monad import qualified Data.ByteString.Char8 as B import Data.Maybe (fromJust) import Text.Printf import Debug.Trace rot i xs = snd $ until ((==0) . fst) (\(i,ys) -> (i-1,rotr ys)) (i,xs) rotr xs = if null (head xs) then [] else (reverse $ map head xs) : rotr (map tail xs) zoom k = foldr f [] where f x acc = replicate k (concat (map (replicate k) x)) ++ acc main = do [r,k] <- getInts [h,w] <- getInts ss <- zoom k <$> rot (r `div` 90) <$> replicateM h getLine mapM_ putStrLn ss -- util getInts :: IO [Int] getInts = map (fst . fromJust . B.readInt) . B.words <$> B.getLine substr :: Int -> Int -> B.ByteString -> B.ByteString substr b l s = B.take l $ B.drop b s