result = ""
while true do
  h, w = gets.chomp.split.map(&:to_i)
  break if h == 0 && w == 0
  result += "#"*w + "\n"
  (h-2).times{ result += "#" + "."*(w-2) + "#" + "\n" }
  result += "#"*w + "\n\n"
end
puts result.chomp + "\n"
