Synthesis of heterocyclic compounds of pharmaceutical interest from conjugated acetylenic and allenic nitriles