import           Control.Applicative
import           Data.Functor

main :: IO ()
main = do
  [h,w] <- fmap read . words <$> getLine
  if (h,w) == (0,0)
    then pure ()
    else printFrame h w >> main

printFrame :: Int -> Int -> IO ()
printFrame h w = putStrLn $ unlines frame
  where
    line_inner = "#" ++ replicate (w-2) '.' ++ "#"
    line_outer = replicate w '#'
    frame = [line_outer] ++ replicate (h-2) line_inner ++ [line_outer]

