Solution (source code)

= Solution
{c}

If $P\equiv P'\pmod Q$, then $P\equiv P'\pmod p$ for each <prime factor> $p$ of $Q$. The <Legendre symbol> depends only on the numerator's <residue class>, so the corresponding factors agree. Also $\gcd(P,Q)=\gcd(P',Q)$, covering the zero cases. Multiplying gives
$$
\boxed{\left(\frac P Q\right)=\left(\frac{P'}Q\right).}
$$
The convention for denominator $1$ gives the same conclusion there.