import Control.Applicative
import Control.Monad

solver :: Int -> Int -> Int -> [String]
solver 1 _ w = [concat (replicate w "#")]
solver n h w =
  if n == h
    then concat (replicate w "#") : solver (n-1) h w
  else
    ("#" ++ concat (replicate (w - 2) ".") ++ "#") : solver (n-1) h w


main :: IO()
main = do
  (h:w:_) <- map (read :: String -> Int) . words <$> getLine
  unless (h == 0 && w == 0) $ do
    mapM_ putStrLn $ solver h h w
    putStrLn ""
    main