module Main where

import Control.Applicative
import Numeric

main :: IO ()
main = loop

loop :: IO ()
loop  = do
  { [h, w] <- getInts
  ; if h == 0 && w == 0 then done
    else do
      { putStrLn $ unlines $ frame h w
      ; loop 
      }
  }

tedge :: Int -> String
tedge n = replicate n '#'

mbody :: Int -> String
mbody n = case n of
          0 -> ""
          1 -> "#"
          _ -> "#" ++ replicate (n-2) '.' ++ "#"

frame :: Int -> Int -> [String]
frame h w = case h of
          0 -> []
          1 -> [tedge w]
          _ -> [tedge w] ++ replicate (h-2) (mbody w) ++ [tedge w]
  

--

getInts :: IO [Int]
getInts = map read . words <$> getLine

putInts :: [Int] -> IO ()
putInts = putStrLn . unwords . map show

getDoubles :: IO [Double]
getDoubles = map read . words <$> getLine

putDoubles :: [Double] -> IO ()
putDoubles = putStrLn .unwords . map showDouble

showDouble :: Double -> String
showDouble d = showFFloat Nothing d ""

done :: IO ()
done = return ()

