--AOJ Print a Frame

import Control.Applicative

rInt :: String -> Int
rInt str = read str :: Int

strFrame :: Int -> Int -> String
strFrame h w = replicate w '#'  ++ "\n"
               ++ concat (replicate (h - 2) ("#" ++ replicate (w - 2) '.' ++ "#\n"))
               ++ replicate w '#' ++ "\n"
               ++ "\n" 

main :: IO ()
main = do
  xs <- pure (map rInt . words) <*> getLine
  let h = head xs 
      w = last xs      
  if h == 0 && w == 0
    then return ()
    else do
    putStr $ strFrame h w
    main