Lewis Hamilton extends contract with Mercedes to race F1 into his 40s