ARGF.each_line do |line|
  h, w = line.split.map(&:to_i)
  break if h == 0 && w == 0
  rec = ("#" * w) + "\n"
  rec += ("#" + "." * (w - 2) + "#" + "\n") * (h - 2)
  rec += ("#" * w) + "\n\n"
  puts rec
end