Detection of nitrogen and oxygen in a galaxy at the end of reionization