def draw_frame(w, h)
  puts "#" * w
  (h - 2).times { puts "#" + ("." * (w - 2)) + "#" }
  puts "#" * w
end

while line = gets.chomp
  break if line == "0 0"
  h, w = line.split(" ").map(&:to_i)
  draw_frame(w, h)
  puts
end