nyu = true

while nyu == true do
  x, y= gets.chomp.split(" ").map(&:to_i)
  if x == 0 && y == 0
    nyu = false
  else
    y.times do
      print "#"
    end
    puts ""

    (x - 2).times do
      print "#"
      (y - 2).times do
        print "."
      end
      print "#"
      puts ""
    end

    y.times do
      print "#"
    end
    puts ""
    puts ""
  end
end



