12487 - Dictionary Order   

Description

A permutation, also called an “arrangement number” or “order,” is a rearrangement of the elements of an ordered list into a one-to-one correspondence sequence.

ORDER is important !! You should display it in dictionary order.(also known as lexical order alphabetical order or lexicographic(al) product

Please solve it by "recursion" or "loop". 

No point if you use C++ STL !!!! 

ex. N=c, 

a b c 
a c b 
b a c 
b c a 
c a b 
c b a 

 

Input

N

N is a alpahbet. N could be a,b,c,d,e,f.

 

Output

S_1

S_2

.

.

.

S_? 

You need to change line even in the last line.

Sample Input  Download

Sample Output  Download

Tags




Discuss