Let $n,a,d$ be given integers with $(a,d) = 1$.
Let $m = a + q*d$ where q is the product of all primes which divide n but not a.
Prove that $m \equiv a \; (mod \; d)$ and $(m,n) = 1$.
The first part follows from the rules of congruences.
$(m,n) = (a +q*d,n) = \ldots$
My idea would be to apply the Euclid property $(a,b) = (a-bq,b)$ here. However, I didn't manage to go so far with it.
Do you see alternative strategies?
References
Apostol, Introduction to Analytic number theory, Exercise 4.