Well it only involves expanding like this:
Then you have to group coefficients with a common degree. I will work out the second one as an example:
Lets write for ease of typing.
Now use to expand.
Group terms with common powers...
Thus comparing it with your first image:
So substitute back and get the final answer...