Electron energy distributions in plasmas IV. Oxygen and nitrogen