Reactions of functionally substituted unsaturated five- and six-membered cyanolactones with α- and β-hydroxy ketones in the presence of sulfuric acid gave substituted 2-oxofuran- and 2-oxopyran-3-carboxamides. Hydrolysis of some keto amides thus obtained afforded the corresponding carboxylic acids, and reactions with hydrazines and semicarbazides led to hydrazones and semicarbazones at the side-chain oxo group.