Beam-induced reactions in molecular secondary ion mass spectrometry. Nitryne and methyne transfer at interfaces