Competition between CO and N2 desorption from interstellar ices