Israel and Hamas reach agreement to extend ceasefire