import Control.Monad

intermediate :: Int -> String
intermediate w
    | w == 1    = "#"
    | w == 2    = "##"
    | otherwise = "#" ++ replicate (w - 2) '.' ++ "#"

solve :: [Int] -> IO ()
solve [h, w] = do
    putStrLn $ replicate w '#'
    when (2 <= h) $ do
        replicateM_ (h - 2) (putStrLn $ intermediate w)
        putStrLn $ replicate w '#'
    putStrLn ""

main :: IO ()
main = getContents >>= mapM_ solve . takeWhile (\[h, w] -> h /= 0 || w /= 0) . map (map read . words) . lines