loop do
  h, w = gets.chomp.split.map(&:to_i)
  break if h == 0 && w == 0
  for j in 0..(h - 1) do
    s = ""
    for i in 0..(w - 1) do
      s += (i == 0 || i == w - 1 || j == 0 || j == h - 1) ? "#" : "."
    end
    puts s
  end
  puts "\n"
end
