Let $f(x,y),g(x,y)$ be two primitive quadratic forms of discriminant $D < 0$. Then the following statements are equivalent:
(i) $f(x,y)$ and $g(x,y)$ are in the same genus i.e. they represent the same values in $(\Bbb Z/D \Bbb Z)^*$.
(ii) $f(x,y)$ and $g(x,y)$ are equivalent modulo $m$ for all nonzero integers $m$.
$(ii) \implies (i)$ is trivial, however I cannot do the other part. A hint given in this problem is to use the complete character of the genera. I cannot make any progress. Please help.