Late Accretion and the Origin of Water on Terrestrial Planets in the Solar System