General method A for the synthesis of compounds 18, 26, 27 and 29