import Control.Applicative
import Control.Monad
main = do
    [h, w] <- (map read . words) <$> getLine
    printAFrame h w

printAFrame :: Int -> Int -> IO()
printAFrame 0 0 = putStr ""
printAFrame h w = do
    putStrLn $ replicate w '#'
    replicateM_ (h - 2) $ do
        putStrLn $ "#" ++ (replicate (w - 2) '.') ++ "#"
    putStrLn $ replicate w '#'
    putStrLn ""
    [h, w] <- (map read . words) <$> getLine
    printAFrame h w