while true
  h,w = gets.chomp.split(" ").map &:to_i
  break if w == 0 and h == 0

  f = ""
  b = ""
  w.times { |i|
   f << "#"
   if i == 0 or i == w-1
     b << "#"
   else
     b << "."
   end
  }

  h.times { |i|
    if i == 0 or i == h-1
      puts f
    else
      puts b
    end
  }

  puts
end