Synthesis of 1,2- and 1,4-dihydropyridines