31. [23] Let
$$
P=\prod_{i=0}^{2016}\left(i^{3}-i-1\right)^{2} .
$$

The remainder when $P$ is divided by the prime 2017 is not zero. Compute this remainder.
Answer: 1994
Solution 1: Let $Q(x)=x^{3}-x-1=(x-a)(x-b)(x-c)$, for $a, b, c \in F_{p^{3}}$. Then, we can write
$$
P=\prod_{i=0}^{2016}(i-a)(i-b)(i-c) .
$$

If we consider each root separately, then
$$
P=-\left(a^{2017}-a\right)\left(b^{2017}-b\right)\left(c^{2017}-c\right) .
$$

The key observation is that $a^{2017}, b^{2017}, c^{2017}$ is some nontrivial cycle of $a, b, c$. This is because by Frobenius' identity, $(a+b)^{p}=a^{p}+b^{p}$. So, if $P(x)=0, P\left(x^{2017}\right)=0$. But, $x^{2017} \neq x$, since $x \notin \mathbb{F}_{p}$. This implies the claim. So, in the end, we wish to compute
$$
(b-a)^{2}(c-b)^{2}(a-c)^{2} \text {. }
$$

Note that $P^{\prime}(x)=3 x^{2}-1=(x-b)(x-c)+(x-a)(x-b)+(x-c)(x-a)$. So it suffices to compute
$$
\left(1-3 a^{2}\right)\left(1-3 b^{2}\right)\left(1-3 c^{2}\right)=-27 P\left(\frac{1}{\sqrt{3}}\right) P\left(-\frac{1}{\sqrt{3}}\right) .
$$

We can compute this is equal to $-27\left(1-\frac{2}{3 \sqrt{3}}\right)\left(1+\frac{2}{3 \sqrt{3}}\right)=-23$.
Alternatively, this is the discriminant of $P(x)$. We utilize the well-known formula that the discriminant of $x^{3}+a x+b$ is $-4 a^{3}-27 b^{2}=-23$. So, the answer is 1994 .