-- Structured Program I - Print a Frame

import Control.Applicative

main :: IO ()
main = do
  xs <- map words . takeWhile (/= "0 0") . lines <$> getContents
  mapM_ putStrLn $ map (frame . map read) xs

frame :: [Int] -> String
frame [h, w] = a ++ (concat $ replicate (h - 2) b) ++ a
  where
    a = replicate w '#' ++ "\n"
    b = '#' : replicate (w - 2) '.' ++ "#\n"

