This was the given solution for round #383 (Div 2) problem C:
The problem statement: Here
The solution:
Make a directed graph and put edge from i and crushi. If the graph has vertex such that its in-degree is 0 then obviously answer doesn't exists. Otherwise the graph consists of some cycles. For each cycle suppose that its length is len. If it has odd length, add len to S, otherwise, add len / 2.
Answer is the LCM of numbers in S.
I am unsure why the LCM is the answer. Is anyone able to advise me?