input1 :: IO [[Int]]
input1 = loop []
  where
    loop list = do
      temp <- getLine
      let [h,w] = map read . words $ temp :: [Int]
      if h == 0 && w == 0
        then return list
        else do
        loop (list ++ [[h,w]])


solve2 [h,w] = loop h
  where
    loop x = do
      if x == 0
        then putStrLn ""
        else do
        if x == h || x == 1
          then do
          putStrLn $ concat $ replicate w "#"
          loop (x-1)
          else do
          putStrLn $ "#" ++ (concat $ replicate (w-2) ".") ++ "#"
          loop (x-1)


main = do
  hws <- input1
  mapM_ solve2 hws

