Phase 3 / permutation, cycles, greedy
Phase 4 / cycle_decomposition, gcd
Phase 1 / graph, dfs, coloring