import Text.Printf
main = do
  str<-getLine
  let [h,w]=map read $ words $ str::[Int]
  if(h==0 && w==0)
  then return ()
  else do
    putStrLn $ replicate w '#'
    putStr $ concat $ replicate (h-2) $ "#"++(replicate (w-2) '.')++"#\n"
    putStrLn $ replicate w '#'
    main