[SOLVED]Prove sqrt(q) is irrational

Let q $\displaystyle \geq$ 2 be such that $\displaystyle \forall a \in \mathbb{Z} \forall b \in \mathbb{Z}$, q|ab $\displaystyle \longrightarrow $ q|a or q|b. Show that $\displaystyle \sqrt q$ is irrational.

The hint of the book said to imitate the proof that $\displaystyle \sqrt 2$ is irrational. I did it by letting $\displaystyle x^2=q$ and assuming $\displaystyle x = \sqrt q$ is rational. So $\displaystyle x = \frac{m}{n}$ and then $\displaystyle x^2= q = \frac{m^2}{n^2}$ . Thus, $\displaystyle qn^2=m^2$.

From here, I must consider if m is even or odd. If m is odd, it must follow that both q and $\displaystyle n^2$ is odd.

It does not seem I could reach any contradiction from the assumption $\displaystyle \forall a \in \mathbb{Z} \forall b \in \mathbb{Z}$, q|ab $\displaystyle \longrightarrow $ q|a or q|b.

Please help, thanks a lot.