printFrame [h,w] = unlines $ e : (center (h-2) (w-2)) ++ [e]
	where e = replicate w '#'

center 0 _ = []
center n w = ('#' : replicate w '.' ++ ['#']) : center (n-1) w

main = getContents >>= mapM_ putStrLn . map (printFrame . map read . words) . init . lines