cycles function

Generates all the orderings of a