you use the distributive law of multiplication.
that law states:
a * (b + c) = a*b + a*c
(a + b) * (c + d) = a*c + a*d + b*c + b*d
here's my worksheet using this law on your problem.
this particular problem would generically be as follows:
(a + b + c) * (d + e + f)
equals a * (d + e + f)
+ b * (d + e + f)
+ c * (d + e + f)
which equals (a*d) + (a*e) + (a*f)
+ (b*d) + (b*e) + (b*f)
+ (c*d) + (c*e) + (c*f)
which equals ad + ae + af
+ bd + be + bf
+ cd + ce + cf
the rest was just combining like terms.
to test if you did it correctly, then choose a random value for x and evaluate the original expression and the final expression.
if they both come up with the same answer, then you did good.
i used x = 25 and came up with 5016539 using both the original expression and the final expression, so i think i did good.