Photodesorption and product formation in UV-irradiated N2 and NH3 ices under ultra-high-vacuum conditions