import Data.List (intercalate)

draw :: Int -> Int -> IO ()
draw w h = drawEachLine w
  where drawEachLine n
          | n == w || n == 1 = drawFrame h >> drawEachLine (n - 1)
          | n > 1            = drawLine  h >> drawEachLine (n - 1)
          | otherwise        = putStrLn "" >> return ()
        drawFrame n = putStrLn $ intercalate "" (replicate n "#")
        drawLine  n = putStrLn $ "#" ++ (intercalate "" $ replicate (n - 2) ".") ++ "#"

main :: IO ()
main = do
    line <- getLine
    let [w, h] = map (\n -> read n :: Int) $ words line
    if w == 0 && h == 0 then
        return ()
    else do
        draw w h
        main
