The least value of the function $x^2+px+q$ is $3$, and this occurs when $x=-2$. Find the values of $p$ and $q$.