while true
  h,w = gets.split.map{|v|
    v.to_i
  }
  if h == 0 && w == 0
    break
  end
  
  print "#" * w, "\n"
  (h-2).times do
    print "#", "." * (w-2) ,"#", "\n"
  end
  print "#" * w, "\n"
  print "\n"
end
