Started working on solution for P40
Finalized solution for P40, runs in under 1 second