main = 
    interact (calc . map (read) . words)

calc :: [Int] -> String
calc (0:0:_) = ""
calc (h:w:xs) = 
    ln h w h ++ "\n" ++ calc xs

ln :: Int -> Int -> Int -> String
ln 0 _ _ = ""
ln h w max
    | h == 1 || h == max = (replicate w '#') ++ "\n" ++ ln (h-1) w max
    | otherwise = "#" ++ (replicate (w - 2) '.') ++ "#" ++ "\n" ++ ln (h-1) w max

