Div II, 500 points

Given a set p[], rec() is a generator of the set of permutations of p[], in O(n!) time.

Keep this technique in mind for future brute-force solutions.