Thermodynamic driving force in the formation of hexagonal-diamond Si and Ge nanowires