I don't see how it matters. If the n's are supposed to be prime, they are going to be coprime to absolutely everything smaller than themselves. Unless you mistyped something in the question? Or I'm missing something..
Something's missing ... It's kinda vague ... as it's written now, you could basically remove the parts about m, so you're basically looking for the primes between 2 and 10 million....