f:: [Int] -> IO()
f [0,0] = return()
f [h,w] = do
    putStrLn $ replicate w '#'
    putStr $ unlines $ replicate (h-2) $ "#" ++ replicate (w -2) '.' ++ "#" 
    putStrLn $ replicate w '#'

main = getContents >>= mapM_ f . map (map read) . (map words) .  lines
