Two solids P and Q of equal mass are heated to the same temperature and…