Solution for P1 is working and tested