Phase transition mechanism of hexagonal graphite to hexagonal and cubic diamond: ab initio simulation