1,2,4-triazoles and 1,3,4-oxadiazoles from N-acylhydrazidines