Tandem [8 + 2] cycloaddition--[2 + 6 + 2] dehydrogenation reactions involving imidazo[1,2-a]pyridines and imidazo[1,2-a]pyrimidines.