main :: IO()
main = do
  inputs <- getContents
  let specs = [ map (\x ->read x ::Int) $ words line | line <- lines inputs, length(line) > 0]
  mapM_ drawFrame specs

drawFrame :: [Int] -> IO()
drawFrame [h,w]
          | (h,w) == (0,0) = return()
          | otherwise = do envelope '#' (w-2) $ getRect '.' (h-2) (w-2)

getRect :: Char -> Int -> Int -> [String]
getRect x h w = replicate h $ (replicate w x)

envelope :: Char -> Int -> [String] -> IO()
envelope x w rect = do putStrLn $ concat $  map (\line -> [x] ++ line ++ [x, '\n']) $ [replicate w x]  ++ rect ++ [replicate w x]