The effect of hydrogen on the formation of carbon nanotubes and fullerenes