import Control.Applicative
import Data.Function
import Control.Monad

main :: IO ()
main = fix $ \loop -> do
    [h,w] <- map read . words <$> getLine
    unless (h == 0) $ do
        putStrLn $ replicate w '#'
        replicateM_ (h-2) $ putStrLn $ "#" ++ (replicate (w-2) '.') ++ "#"
        putStrLn $ replicate w '#'
        putStrLn ""
        loop

