Egypt survive Benin scare to reach Cup of Nations quarter-finals