Ab initio calculations of the phase diagrams of tin and lead under pressures up to a few TPa