Thank's for the help. I can see the truth of the final congruence and will write my argument down. But is there a more susinct argument?
Each summand on the LHS contributes to the sum (mod 4) if none of the following statements are true:
(mod 4)
(mod 4)
That is they contribute iff
(mod 4)
And the sum is equal to the number of contributions (mod 2). The number of p_j such that (mod 4) and the number of q_i such that (mod 4) must both be odd or the sum is zero (mod 2).
Now
where r is the number of p_j that equal 3 (mod 4). Therefore, if there are an even number of p_j that equal 3 (mod 4) and otherwise. In conclusion the sum is only non zero if .
Similarly the sum is only non zero if .
Now if or . Conversely (mod 2) if and .