simplified p8 solution
solved p10