{-# LANGUAGE MultiWayIf, BangPatterns #-}
import Control.Monad

main :: IO ()
main = do
  [h, w] <- map read . words <$> getLine
  !al <- replicateM h $ map (== '#') <$> getLine
  let
    red = do
      i <- [1..h]
      return $ flip map [1..w] $ \j -> if
        | j == 1 -> True
        | j == w -> False
        | odd i  -> True
        | otherwise -> False
    blue = flip map red $ map not
    po c = zipWith (zipWith (||)) c al
    showColor = map (\b -> if b then '#' else '.')
  putStrLn $ unlines $ map showColor (po red)
  putStrLn $ unlines $ map showColor (po blue)
