Germany reaches deal with Spain to return migrants