loop do
  h, w = gets.chomp.split.map(&:to_i)
  break if h == 0 && w == 0
  count_w = 0
  h.times {
    if count_w == 0 || count_w == h - 1
      puts "#" * w
    else
      puts "#" + "."*(w-2) + "#"
    end
    count_w += 1
  }
  puts
end
