UVa 10098 - Generating Fast

Summary
Generate all unique permutations in sorted order.

Explanation
Use the C++ stl permutation and you should be able to pass the tests.

Input
3 ab abc bca

Output
ab ba

abc acb bac bca cab cba

abc acb bac bca cab cba