Replace each set by a sum of powers of x. Let p be a prime like 5 dividing n. Under your condition 1+ x + x^2 + x^3 + x^4 would divide both polynomials. Show it only divides the product once. I'd be less coy but I am typing this on a phone in a power outage! I've used those ideas to great effect. If n is prime then one set not only is not distinct mod n but actually has all elements equal mod n.