2126. Permutations

单点时限: 2.0 sec

内存限制: 256 MB

Given a word, write a program to generate all its permutations in lexicographic order.

输入格式

The input will consist of several words. The first line contains the number of words. It is followed by that many words, each appearing in single line. The words will have both uppercase and lowercase letters in them, and they are to be considered different.

输出格式

For each given word in the input, print its all possible permutations, each on a different line. The different permutations should be printed in lexicographic order. An uppercase letter goes before the corresponding lowercase letter.

hint: A<a<B<b.....

样例

Input
2
aAb
acba
Output
Aab
Aba
aAb
abA
bAa
baA
aabc
aacb
abac
abca
acab
acba
baac
baca
bcaa
caab
caba
cbaa

23 人解决,56 人已尝试。

40 份提交通过,共有 231 份提交。

6.3 EMB 奖励。

创建: 16 年,7 月前.

修改: 7 年,3 月前.

最后提交: 1 年,9 月前.

来源: Codewars 2006

题目标签