Synthesis of nitrogen-rich imidazole, 1,2,4-triazole and tetrazole-based compounds