Physical properties of GaN and AlN under pressures up to 0.5 Mbar