loop do
  h, w = gets.chomp.split(" ").map(&:to_i)
  break if h == 0 && w == 0
  puts "#" * w
  while (h - 2 > 0) do
    puts "#" + "." * (w - 2) + "#" 
    h -= 1
  end
  puts "#" * w if h >= 2
  puts ""
end