Solution (source code)

= Solution
{c}

Factor $Q=\prod_i p_i$ and $Q'=\prod_j q_j$, retaining repeated <prime factors>. If $P$ has a common <prime factor> with $QQ'$, it has one with at least one of $Q,Q'$, and both sides of the desired equality are zero. Otherwise the definition of the <Jacobi symbol> gives
$$
\boxed{\left(\frac P{QQ'}\right)=\prod_i\left(\frac P{p_i}\right)\prod_j\left(\frac P{q_j}\right)=\left(\frac P Q\right)\left(\frac P{Q'}\right).}
$$
An empty product is $1$, so the argument includes either denominator being $1$.