main = do
  s <- getContents
  putStrLn . concat . map rect2 . takeWhile (/=[0,0]) . map (map (read :: String -> Int) . words) . lines $ s

rect2 :: [Int] -> String
rect2 [1,w] = row "#" w ++ "\n"
rect2 [h,w] = (row "#" w) ++ (concat . take (h-2) . repeat $ (row "." w)) ++ (row "#" w) ++ "\n"

row :: String -> Int -> String
row _ 1 = "#"
row t w = "#" ++ (concat . take (w-2) . repeat $ t) ++ "#\n"