
arr = []
while true
  val1, val2 = gets.split(" ").map(&:to_i)
  break if val1.zero? && val2.zero?
  arr << [ val1, val2 ]
end

arr.each do |val|
  str = ""
  val[0].times do |ind1|
    val[1].times do |ind2|
      if ind1 == 0
        str += "#"
      elsif ind2 == 0
        str += "#"
      elsif ind1 == (val[0] - 1)
        str += "#"
      elsif ind2 == (val[1] - 1)
        str += "#"
      else
        str += "."
      end
    end
    str += "\n"
  end
  print "\n"
  print str
end