Probing photoexcitation dynamics in molecules by ultrafast soft X-ray absorption spectroscopy at the nitrogen K-edge