Solution (source code)

= Solution
{c}

The second supplementary law for the <Legendre symbol> is $(2/p)=(-1)^{(p^2-1)/8}$. To multiply these signs, observe that for odd $a,b$,
$$
\frac{a^2b^2-1}{8}-\frac{a^2-1}{8}-\frac{b^2-1}{8}=\frac{(a^2-1)(b^2-1)}8.
$$
Both factors in the numerator are divisible by $8$, so the right side is even. Applying this identity repeatedly to the <prime factorization> gives
$$
\boxed{\left(\frac2Q\right)=\prod_i(-1)^{(p_i^2-1)/8}=(-1)^{(Q^2-1)/8}.}
$$
Again the convention at $Q=1$ agrees.