We have 8m=xm+p.
Then substracting both side with xm we get
8m-xm=p.
Using distribution rule, we have
(8-x)m=p
Assuming x is not equal to 8, we divide both side by (8-x) to get (if x equals to 8 then we divide by zero which is absurd, so the restriction is necessary)
m=p/(8-x)