(p^2-7)(p+8)

p^2(p+8) -7(p+8)

Finish the multiplications and add up the terms