Solution for p9.