EU leaders agree on plan for migrants