main = mapM_ process . takeWhile (/= "0 0") . lines =<< getContents
  where process line = do
                          putStrLn $ replicate w '#'
                          putStr $ unlines (replicate (h-2) $ "#"++(replicate (w-2) '.')++"#")
                          putStrLn $ replicate w '#'
                          putStrLn ""
                          where [h,w] = map (read::String->Int) $ words line