main :: IO ()
main = do
    line <- getLine
    case (words line) of
      ["0", "0"] -> return ()
      [h, w] -> do
          printFrame (read h :: Int) (read w :: Int)
          main

printFrame :: Int -> Int -> IO ()
printFrame h w = do
    putStrLn $ replicate w '#'
    mapM_ putStrLn $ replicate (h-2) ("#" ++ (replicate (w-2) '.') ++ "#")
    putStrLn $ replicate w '#'
    putStrLn ""