ARGF.each_line do |line|
  h, w = line.split.map(&:to_i)
  i = 0
 while (h >= 3 && w <= 100) do
  i += 1
  break if [h, w].eql? [0, 0]
    case i
    when 1, h
      puts '#' * w
    when h + 1
      break
    else
      print "#", ("." * (w - 2)), "#\n"
    end
  end
  puts
end