import Control.Applicative
import Control.Monad
import Data.List

f :: String -> String
f []     = []
f (x:xs) = x : x : f xs

main :: IO ()
main = do
    [h, w] <- fmap read . words <$> getLine :: IO [Int]
    xss <- replicateM h getLine
    let xss' = transpose . fmap f $ transpose xss
    putStrLn $ unlines xss'