loop{
    h,w = gets.split.map(&:to_i)
    if h == 0 && w == 0
        break
    end
   puts "#" * w
   sum = h - 2
   sum.times{
       r = "#"
       dot = "."
       dod = w - 2
       puts "#{r}#{dot*dod}#{r}"
   }
   puts "#" * w
   puts ""
}
