On the origin and evolution of isotopes of carbon, nitrogen, and oxygen