loop do
h,w = gets.split.map {|eee|eee.to_i}
break if h == 0 and w == 0
h.times do |i|
  if i == 0 or i == h-1
    w.times do
      print("#")
    end
    print("\n")
  else
    if w <= 2
      w.times do
        print("#")
      end
      print("\n")
    else
      print("#")
      (w-2).times do
        print(".")
      end
      print("#\n")
    end
  end
end
  print("\n")
end
