In David Cox's book: Primes of the form $x^2+ny^2$, second edition, there is a theorem(Theorem 3.21, page 52) characterize whether two binary quadratic forms in the same genus. The contents of the theorem are: Let $f(x,y)$ and $g(x,y)$ be primitive forms of discriminant $D\neq0$, positive definite if $D<0$. Then the following are equivalent: (i) $f(x,y)$ and $g(x,y)$ are in the same genus, i.e., they represent the same values in $(\mathbb Z/D\mathbb Z)^\ast$. (ii) $f(x,y)$ and $g(x,y)$ represent the same values in $(\mathbb Z/m\mathbb Z)^\ast$ for all nonzero integer $m$. (iii) $f(x,y)$ and $g(x,y)$ are equivalent modulo $m$ for all nonzero integer $m$. (iv) $f(x,y)$ and $g(x,y)$ are equivalent over the $p$-adic integer $\mathbb{Z}_p$ for all primes $p$. (v) $f(x,y)$ and $g(x,y)$ are equivalent over $\mathbb Q$ via a matrix in $GL_2(\mathbb Q)$ whose entries have denominators prime to $2D$. (vi) $f(x,y)$ and $g(x,y)$ are equivalent over $\mathbb Q$ without essential denominators, i.e., given any nonzero $m$, a matrix in $GL_2(\mathbb Q)$ can be found which takes one form to the other and whose entries have denominators prime to $m$. The author does not give details of the proof, only some references. **Question:** How to derive (ii) and (iii) from (i), and how to prove the equivalence of (iv) and (vi). Could someone please give me some hints?