全排列STL
#include <iostream>
#include <algorithm>
#include <cstring>
using namespace std;
int main(){
int t;
cin >> t;
while(t--){
char s[100];
cin >> s;
int l=strlen(s);
sort(s,s+l);
do{
for (int i = 0; i < l;i++) cout << s[i];
cout << endl;
}while(next_permutation(s,s+l));
cout << endl;
}
return 0;
}