Synthesis of heterocycles via cycloadditions