i think we can solve the first problem like this
xr1yr2zr3wr4 will be at term if
r1+r2+r3+r4 =n
so we need to find the number of sets (r1 ,r2 ,r3 ,r4 ;integral set o'course)
that satisfies the above condition :
this is equal to n+3Cn=(n+3)(n+2)(n+1)6