Problem:
Print a Frame

Draw a frame which has a height of H cm and a width of W cm. For example, the following figure shows a frame which has a height of 6 cm and a width of 10 cm.

##########
#........#
#........#
#........#
#........#
##########

Input

The input consists of multiple datasets. Each dataset consists of two integers H and W separated by a single space.

The input ends with two 0 (when both H and W are zero).

Output

For each dataset, print the frame made of '#' and '.'.

Print a blank line after each dataset.

Constraints

3 ≤ H ≤ 300

3 ≤ W ≤ 300

Sample Input

3 4
5 6
3 3
0 0

Sample Output

####
#..#
####

######
#....#
#....#
#....#
######

###
#.#
###

Solution in Ruby (judge verdict: Accepted)

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