import Control.Applicative
import Control.Monad

printFrame :: Int -> Int -> IO()
printFrame h w = do
    putStrLn $ replicate w '#'
    replicateM_ (h - 2) (putStrLn $ ("#" ++ (replicate (w - 2) '.') ++ "#"))
    putStrLn $ replicate w '#'

main :: IO()
main = do
    args <- (map (read :: String -> Int) . words) <$> getLine
    if (args == [0, 0])
    then return ()
    else do
        printFrame (args !! 0) (args !! 1)
        putStrLn ""
        main