import Data.List.Split

main = do
  hw <- getTwoNum
  case hw of
    (0,0) -> return ()
    (h,w) -> do 
	  mapM_ putStrLn $ createScreen h w
	  putStrLn ""
	  main

createScreen :: Int -> Int -> [String]
createScreen h w = map create_ [1..h]
  where 
    create_ h'
      | h' == 1   = replicate w '#'
      | h' == h   = replicate w '#'
	  | otherwise = '#' : replicate (w-2) '.' ++ "#"

getTwoNum :: IO ((Int,Int))
getTwoNum = do
  (a:b:_) <- getNums
  return (a,b)

getNums :: IO ([Int])
getNums = do
  s <- getLine
  return $ map read $ splitOn " " s
