main = interact $ unlines . map (print_frame . map read . words) . init . lines
print_frame [h,w] = unlines $ [replicate w '#'] ++ replicate (h-2) ("#" ++ replicate (w-2) '.' ++ "#") ++ [replicate w '#']