#include <cstdio>
#include <algorithm>
#include<string>
using namespace std;
int main() {
    string s;
    char arr[7];
    while (scanf("%s",arr) != EOF) {
        string s = arr;
       printf("%s\n",s.c_str());
        for (s.begin(); next_permutation(s.begin(), s.end());) {
            printf("%s\n",s.c_str());
        }
        printf("\n");
    }
    return 0;
}