proving √q is irrational by contradiction

Let q≥2 be a positive integer. If for all integers a and b, whenever q|ab, q|a or q|b, then √q is irrational.

I know I should do a proof by contradiction so i should assume √q is rational, and that for all integers a and b if q|ab then q|a or q|b.

So since √q is rational it can be written as m/n where m and n are integer and are relatively prime.

So √q=m/n. Squaring both sides q=m^2/n^2. Then q(n^2)=m^2.

I got stuck at this point. I think im suppose to show q|m and q|n to show a contradiction but im not sure how to get there.

Anything helps!! thanks!