#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <cstdio>
#include <cstring>
using namespace std;

char s[11];

int main()
{
    int times = 0;
    int T;
    scanf("%d", &T);
    while(T--)
    {
        scanf("%s", s);
        int n = strlen(s);
        sort(s, s+n);
        do
        {
            printf("%s\n", s);
        }while(next_permutation(s, s+n));
        printf("\n");
    }
    return 0;
}
posted on 2012-09-24 17:25  有间博客  阅读(125)  评论(0编辑  收藏  举报