The terrestrial planets

Primary atmosphere of the terrestrial planets were composed almost entirely of hydrogen and helium. Explain why they contained these gases and not others.