Here is the solution for P3