class Main
  def self.run
    frames = read_inputs
    puts frames.map(&:draw).join("\n")
    puts "\n"
  end

  private

  def self.read_inputs
    frames = []
    while true do
      h, w = gets.split(" ").map(&:to_i)
      case [h, w]
        when [0, 0] then break
        else frames << Frame.new(h, w)
      end
    end
    frames
  end
end

class Frame
  def initialize(height, width)
    @height, @width = height, width
  end

  def draw
    output = "#{border}\n"
    (1..inner_height).each {|i|
      output << "##{"." * inner_width}#\n"
    }
    output << "#{border}\n"
  end

  def border
    "#" * @width
  end

  def inner_height
    @height - 2
  end

  def inner_width
    @width - 2
  end
end

Main.run