Like terms are all terms with the same variables and exponents.
For example: #2x^2y# and #-5x^2y# are like terms.
While #3xy# and #-2xz# or #-2ab# and #3ab^2# are not. In the first pair there are different variables (#x# and #z#). The second pair has the same variables (#a# and #b#) but the exponents are different (in the first term #b# is raised to first power #b=b^1# while in the other #b# is squared)
In the example there are 2 pairs of like terms:
#color(red)(4p)color(blue)(-7)color(red)(+6p)color(blue)(+10)#
To combine like terms you have to add coefficients of all like terms:
#color(red)(4p)color(blue)(-7)color(red)(+6p)color(blue)(+10)=color(red)(4p+6p)color(blue)(-7+10)=color(red)(10p)color(blue)(+3)#
The result is: #4p-7+6p+10=10p+3#