Solution for P2