4. Given that the roots of the equation $x^{2}-x-1=0$ are also roots of the equation $x^{6}-p x^{2}+q=0$. Then $p=$ $\qquad$ ,$q=$ $\qquad$ .
4. $p=8, q=-21$.

Let $x_{1}, x_{2}$ be the roots of the equation $x^{2}-x-1=0$, then
$$
\left\{\begin{array}{l}
x_{1}+x_{2}=1, \\
x_{1} x_{2}=-1, \\
x_{1}^{6}-p x_{1}^{2}+q=0, \\
x_{2}^{6}-p x_{2}^{2}+q=0 .
\end{array}\right.
$$

From (1) and (2), we get $x_{1}^{2}+x_{2}^{2}=3, x_{1}^{4}+x_{2}^{4}=7$.
Subtracting (4) from (3) gives
$$
\left(x_{1}^{2}-x_{2}^{2}\right)\left(x_{1}^{4}+x_{2}^{4}+x_{1}^{2} x_{2}^{2}-p\right)=0 .
$$
$$
\begin{array}{l}
\because \quad x_{1} \neq x_{2}, \\
\therefore \quad p=8 .
\end{array}
$$
Adding (3) and (4) gives
$$
\left(x_{1}^{2}+x_{2}^{2}\right)\left(x_{1}^{4}+x_{2}^{4}-x_{1}^{2} x_{2}^{2}\right)-p\left(x_{1}^{2}+x_{2}^{2}\right)+2 q=0 \text {. }
$$

Thus, $q=-21$.