Divide-and-conquer, sort
Primitive root of unity module p
Solve equation: 10^x = 1 (mod n)