{-
ITP1_5-B
Structured Program I - Print a Frame
Time Limit : 1 sec, Memory Limit : 65536 KB
?????¬???????????????

??\????????????????????????H cm ?????? W cm ???????????????????????°?????????????????????????????????

##########
#........#
#........#
#........#
#........#
##########

?????????????????? 6 cm ?????? 10 cm ???????????¨??????????????????
Input

??\???????????°????????????????????????????§???????????????????????????????????????????????????¢????????\????????¨????????§??????

H W

H, W ?????¨?????? 0 ?????¨????????\?????????????????¨????????????

????????????????????¨??????????????\???????????¶??????3 ??? H, W ??? 100 ??§??????
Output

?????????????????????????????????????????? H cm ?????? W cm ?????????????????????????????????

?????????????????????????????????????????????????????\??????????????????
Constraints

H, W ??? 300
Sample Input

3 4
5 6
3 3
0 0

Sample Output

####
#..#
####

######
#....#
#....#
#....#
######

###
#.#
###
-}
import Data.List.Split
import Text.Printf

main = do
  s <- getLine
  let [h,w] = map (\x-> read x::Int) $ splitOn " " s
  if h==0 && w==0 then return()
    else do
      mapM_ (\x->putStrLn $ if x==1 || x==h then aux 1 w
                            else aux 0 w) [1..h]
      printf "\n"
      main

aux :: Int -> Int -> String
aux h w = if h==1 then foldr (\x acc-> "#" ++ acc) "" [1..w]
          else "#" ++ (foldr (\x acc-> "." ++ acc) "#" [1..(w-2)])