Use KMP to solve the cyclic automorphism problem in O(n), add two links for the question.