Prime number $p>3$ is congruent to $2$ modulo $3$. Let $a_k= k^2+k+1$ for $k=1,2,\ldots,p-1$. Prove that product $a_1a_2\cdots a_{p-1}$ is congruent to $3$ modulo $p$.
I tried to solve this problem for two hours, I realized this: $$ a_1\equiv a_{p-1}\pmod p \\ a_2\equiv a_{p-2}\pmod p \\ \vdots \\ a_{(p-3)/2}\equiv a_{(p+1)/2}\pmod p $$
But now I don't know what to do.
Since $a(k) = (k^3-1)/(k-1)$ for $k\ne1$, we have $a(k) \equiv (k^3-1)(k-1)^{-1}\pmod p$ for $2\le k\le p$. Then $$ a(2)a(3)\cdots a(p) \equiv \prod_{k=2}^p (k^3-1) \bigg( \prod_{k=2}^p (k-1) \bigg)^{-1} \pmod p. $$ But since $p\equiv2\pmod3$, the cubes $k^3$ run through a complete set of residues $\pmod p$ as $k$ does (and of course $1^3=1$ is mapped to itself). Therefore, making the change of variables $j=k^3$, we obtain $$ a(2)a(3)\cdots a(p) \equiv \prod_{j=2}^p (j-1) \bigg( \prod_{k=2}^p (k-1) \bigg)^{-1} \equiv 1 \pmod p. $$ The problem now follows on noting that $a(1)=3$ and $a(p) = p^2+p+1\equiv1\pmod p$.