import Control.Applicative
import Control.Monad

frame_in :: Int -> Int -> Char -> Char -> String
frame_in 0 _ _ _ = []
frame_in h w b i = [b] ++ inner ++ [b] ++ ['\n'] ++ frame_in (h - 1) w b i
  where inner = replicate (w - 2) i

frame :: Int -> Int -> Char -> Char -> String
frame 0 _ _ _ = []
frame h w b i = edge ++ ['\n'] ++ frame_in (h - 2) w b i ++ edge ++ ['\n']
  where edge = replicate w b

main = do
  [h, w] <- map (\x -> read x :: Int) . words <$> getLine
  when (h /= 0 || w /= 0) $ putStr (frame h w '#' '.') >> putChar '\n' >> main