Solve p40 and p41