import Data.Functor ((<$>))

main :: IO ()
main = do
  [h, w] <- map (read :: String -> Int) . words <$> getLine
  if h == 0 && w == 0
    then return ()
    else do
      putStrLn $ replicate w '#'
      putStrLn . unlines $ replicate (h-2) $ "#" ++ replicate (w-2) '.' ++ "#"
      putStrLn $ replicate w '#'
      main

