Taking q(x)=1, q(x)=x and q(x)=x^2 in equation (1) and
working out the integral (easy!) will give you three equations
which you can solve to find \lambda_1,\ \lambda_2 and
\lambda_3.
The key to showing that the same formula works for other
polynomials is to show that if it works for 1,\ x and x^2 it
works for any linear combination of them and so for any quadratic
polynomial.
Finally you can go on to check out the formula for x^3,\ x^4 and
x^5.