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 . unlines $ replicate (h - 2) ("#" ++ replicate (w - 2) '.' ++ "#")
            putStrLn $ replicate w '#' ++ "\n"
            main