Origin and evolution of the atmospheres of the terrestrial planets