module Main where

import Data.Functor

main :: IO ()
main =  do
 { [h,w] <- getInts
 ; if h == 0 && w == 0 then done
   else putStrLn (unlines (frame h w)) >> main
 }


frame :: Int -> Int -> [String]
frame h w = tb : (cylindre ++ [tb])
  where
    tb = replicate w '#'
    cy = '#':(bd ++ "#")
    bd = replicate (w-2) '.'
    cylindre = replicate (h-2) cy 

done :: IO ()
done = return ()

getInts :: IO [Int]
getInts = map read . words <$> getLine