import Control.Applicative
import Control.Monad

frame :: Int -> Int -> String
frame h w =
    unlines $ topOrBottom w : replicate (h - 2) (middle w) ++ [topOrBottom w]

topOrBottom :: Int -> String
topOrBottom w = replicate w '#'

middle :: Int -> String
middle w = '#' : replicate (w - 2) '.' ++ "#"

main :: IO ()
main = do
    xss <- fmap (fmap read . words) . lines <$> getContents :: IO [[Int]]
    forM_ (takeWhile (/= [0, 0]) xss) $ \[h, w] -> do
        putStrLn $ frame h w

