import Control.Monad
f x = do
  hw_in <- (return . words) =<< getLine
  let h:w:[] = map (read::String->Int) hw_in
  if (h==0)&&(w==0)
    then return ()
    else do
      forM_ [1..h] (\i -> do
        if (i == 1)||(i == h) then putStrLn ['#'|_<-[1..w]]
        else putStrLn ("#" ++  ['.'|_<-[2..w-1]] ++ "#"))
      putStrLn ""
      f (x+1)
main = f 0
